This is because your output is being fed from get-distributiongroupmember. 
Empty groups have zero members and therefore the cmdlet returns no results. You 
can make this work, but it’s gonna be more complicated. You have to examine the 
result from get-distributiongroupmember and if it is zero, have some kind of 
default output.

From: [email protected] [mailto:[email protected]] On 
Behalf Of Mazzaccaro, David
Sent: Wednesday, November 18, 2015 9:15 AM
To: [email protected]
Subject: RE: [Exchange] Help w/ Powershell script and distribution lists

Thanks, I tried inserting “-resultsize unlimited” after get-distributiongroup 
as well as after get-distributiongroup member $group but it still won’t give me 
empty DLs.
foreach ($group in Get-DistributionGroup –resultsize unlimited) 
{get-distributiongroupmember $group –resultsize unlimited | sort displayname | 
ft @{expression={$_.displayname};Label=”$group”}, 
@{expression={$_.PrimarySmtpAddress};Label=”Emailaddress”} | Out-File 
c:\output\DLMembers.txt -append}

Any other ideas?


From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Micheal Espinola Jr
Sent: Tuesday, November 17, 2015 9:32 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: [Exchange] Help w/ Powershell script and distribution lists

You need to incorporate '-Resultsize Unlimited'

--
Espi


On Tue, Nov 17, 2015 at 6:22 PM, Mazzaccaro, David 
<[email protected]<mailto:[email protected]>> 
wrote:
Hi all,
I am trying to get this Powershell script to include empty distribution lists.
Any ideas?

foreach ($group in Get-DistributionGroup) {get-distributiongroupmember $group | 
sort displayname | ft @{expression={$_.displayname};Label=”$group”}, 
@{expression={$_.PrimarySmtpAddress};Label=”Emailaddress”} | Out-File 
c:\output\DLMembers.txt -append}

Thanks!


Reply via email to