List Distribution Group members Exchange 2010/2013

Distribution Groups:

To check all commands related to Distribution groups

Get-Help *distrib*

To Get list of all distribution groups:

Get-DistributionGroup

To get more details for specific Distribution list

Get-DistributionGroup <listname> | FL
Get-DistributionGroup <listname> | select Displayname, Primarysmtpaddress, Managedby

Now combine the Select Cmdlet with the ExpandProperty Cmdlet to see more information associated with the ManagedBy property.

Get-DistributionGroup <listname> | select Displayname, Primarysmtpaddress -ExpandProperty Managedby

Command to list the managers of all distribution groups.

Get-DistributionGroup  | select Displayname, Primarysmtpaddress -ExpandProperty Managedby | Select Displayname, Primarysmtpddress, name

To export to CSV command looks like this:

Get-DistributionGroup  | select Displayname, Primarysmtpaddress -ExpandProperty Managedby | Select Displayname, Primarysmtpddress, name | Export-CSV c:DGlist.csv

Distribution Group Members
Here now we will have commands to list all members of distribution group in exchange server.

The basic command

Get-DistributionGroupMember
Get-DistributionGroup | Get-DistributionGroupMembers

more detailed results can be found as:

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft alias, @{label=’Test1′;expression={$group.name}}}

and this command will give you all list of members in each distribution group.

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft @{expression={$_.displayname};Label=”$group”}}

To output the data to a file, use the Out-File Cmdlet along with -append.

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft @{expression={$_.displayname};Label=”$group”} | Out-File c:tempDistributionListMembers.txt -append}

To sort alphabetically within each group add the sort displayname into the command as below:

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

 

Also there is a script from Microsoft which do similar action in csv result. Here is the link to download that script

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s