List all distribution groups and their members

Generally, you can simply get the Distribution Groups or it members by using the following Exchange Cmdlet.

  • If we need to get all existing distribution groups, run the Get-DistributionGroup cmdlet.


  • If we want to find all distribution group members, use the Get-DistributionGroupMember cmdlet.



However, some administrator inquires if we can list all the distribution groups and their members in a single result. Based on our tests, we can use the following scripts to list all existing distribution groups and their members.

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | select Name,@{n='DistributionGroupName';e={$group.Name}} }



If there are too many distribution groups and members, you can export the result to a csv file using the scripts below.

$groupmembers = foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | select Name,@{n='DistributionGroupName';e={$group.Name}} }
$groupmembers | Export-Csv C:\DGgroupmembers.csv NoTypeInformation


Then you can find the result in the DGgroupmembers.csv file.


Reference:

Exchange 2007 - enumerate distribution lists members

https://social.technet.microsoft.com/Forums/en-US/1ae1cb17-4fc1-4ac3-824f-dc9c19963f32/exchange-2007-enumerate-distribution-lists-members?forum=exchangesvradminlegacy

Note:

Based on my tests, the above scripts apply to Exchange Server 2007, Exchange Server 2010 and Exchange Server 2013.

December 17th, 2014 9:23am

Ok This works well however the code do not displays DLs with no members (empty DLs) .Please suggest.
Free Windows Admin Tool Kit Click here and download it now
June 10th, 2015 7:35am

You should also account for nested groups.
June 10th, 2015 4:03pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics