Applies to: Exchange Server 2007
The members of Distribution Groups can be viewed and modified through the Outlook Address Book. However, Outlook doesn’t offer a way to export a list of all the members.
Administrators can run the following Exchange Management Shell commands to display/export the memberlist, sorted by DisplayName.
Single Distribution Group
- Display Memberlist
Get-DistributionGroupMember {Name of Group} | Sort -Property DisplayName | Select DisplayName, Alias, Department
- Export Memberlist to TXT file
Get-DistributionGroupMember {Name of Group} | Sort -Property DisplayName | Select DisplayName, Alias, Department > C:DGmemberlist.txt
- Export Memberlist to CSV file
Get-DistributionGroupMemberĀ {Name of Group} | Sort -Property DisplayName | Select DisplayName, Alias, Department | Export-CSV C:DGmemberlist.csv
All Distribution Groups in the Exchange Organization
- Display Memberlist (create a script file called something like C:scriptsGet-DGmembers.ps1, paste below commands into it, and run the file in the Exchange Management Shell)
get-distributiongroup | Sort -Property DisplayName | foreach {
$name = $_.displayname
$output = ‘Group Name: ‘ + $Name
write-output $output
Get-DistributionGroupMember $name | Sort -Property DisplayName | Select DisplayName, Alias, Department
write-output “” “”
}
- Export Memberlist to TXT file (create a script file called something like C:scriptsExport-DGmembers.ps1, paste below commands into it, and run the file in the Exchange Management Shell)
write-output “” > C:outputDGmembers.txt
get-distributiongroup | Sort -Property DisplayName | foreach {
$name = $_.displayname
$output = ‘Group Name: ‘ + $Name
write-output $output >> C:outputDGmembers.txt
Get-DistributionGroupMember $name | Sort -Property DisplayName | Select DisplayName, Alias, Department >> C:outputDGmembers.txt
write-output “” “” >> C:outputDGmembers.txt
}
You are a life saver. I don’t care that this entry was from April 2009, you saved me a ton of work.
Thank you very much.
I’m a fan of lDIFDE and I used your instructions but swapped $name = $_.displayname for $DN = $_.DistinguishedName, as well as just selected the DistinguishedName for the Members part, and outputted to a .ldf file for easy manipulation in NotePad++ and then replaced the members attribute of the matching groups in the domain that I am migrating our customer to.
Fantastic – needed this and it worked perfectly.
Thankyou Wil
thanks for the script. can the data be set for one line?
Super nice… Thank you for sharing