Administrators are frequently asked for a list of distribution groups and their memberships for a number of reasons (auditing, compliance, nosy bosses).  Here's a script that generates that output, one distribution group and member per line, which, can also serve as a great makeshift distribution list backup.  This script can take a long time to run (especially if you have a lot of groups and members), so be prepared to go get a coffee.  You can also adapt this for security group membership if you're so inclined.

This script is also useful for copying distribution lists and contacts between Exchange orgs, preserving the X500 addresses and other proxy addresses for replyability.

For distribution group members that don't exist in the target environment, the script will also create new mail contacts if desired.


Exports a CSV of all distribution groups and members, one group / member 
per line. 
This script will create and export a list of all distribution groups and 
their direct members. The output is in the following format: 
"Distribution Group","DisplayName","PrimarySmtpAddress" 
.PARAMETER CreateContactsForMissingRecipients 
Create a mail-enabled contact for recipients that do not exist in the organization or tenant. 
.PARAMETER CheckForSynchronizedGroups 
When target is an Office 365 tenant, check to see if the group is synchronized. Synchronized groups 
can only be updated on-premises. 
.PARAMETER Filename 
This parameter is used to specify the output file name. 
Specify filter as a domain ( or or as an individual 
SMTP address ( 
Specify a logfile to be created. 
Extract the SMTP address for the ManagedBy attribute. 
Used to select Import or Export mode. 
.PARAMETER OnlyProcessMembers 
Only update group members; don't try to create new groups. 
.\DistributionGroupImportExport.ps1 -Mode Export -Filename DistributionGroups.csv 
Export all distribution groups to file DistributionGroups.csv. 
.\DistributionGroupImportExport.ps1 -Mode Export -Filename DistributionGroups.csv -Filter 
Export all distribution groups matching domain '' to file DistributionGroups.csv. 
.\DistributionGroupImportExport.ps1 -Mode Export -Filename DistributionGroups.csv -Filter 
Export single distribution group '' to file DistributionGroups.csv. 
.\DistributionGroupImportExport.ps1 -Mode Import -Filename DistributionGroups.csv 
Import distribution groups and members from file DistributionGroups.csv. 
.\DistributionGroupImportExport.ps1 -Mode Import -Filename DistributionGroups.csv -CreateContactsForMIssingRecipients 
Import distribution groups and members from file DistributionGroups.csv and create new mail contacts 
for members that are not recipients in the Exchange organization. 
For an updated version of this script, check the Technet 
Gallery at