1. Home
  2. Office 365
  3. Export Office 365 Distribution List Members to CSV
  1. Home
  2. PowerShell
  3. Export Office 365 Distribution List Members to CSV

Export Office 365 Distribution List Members to CSV

The following PowerShell commands can be used to export the members of an Office 365 Distribution Lists to a .csv file.

Export Members of a Single Distribution List

Get-DistributionGroupMember -Identity "DL" -ResultSize Unlimited | Select Name, PrimarySMTPAddress, RecipientType | Export-Csv "FileLocation.csv"
  • The following example exports the Distribution List “DL-Support” to a file called DLSupportMembers.csv in the C:\Export\ folder
  • The exported .csv will display the data in the following format

Export Members of All Distribution Lists

  • The following command can be used to export the members of all Distribution Lists to a .csv file.
  • In the command below you will need to change “FileLocation” to the desired location to save the exported file.
$Result=@()
$groups = Get-DistributionGroup -ResultSize Unlimited
$totalmbx = $groups.Count
$i = 1
$groups | ForEach-Object {
Write-Progress -activity "Processing $_.DisplayName" -status "$i out of $totalmbx completed"
$group = $_
Get-DistributionGroupMember -Identity $group.Name -ResultSize Unlimited | ForEach-Object {
$member = $_
$Result += New-Object PSObject -property @{
GroupName = $group.DisplayName
Member = $member.Name
EmailAddress = $member.PrimarySMTPAddress
RecipientType= $member.RecipientType
}}
$i++
}
$Result | Export-CSV "Filelocation.csv" -NoTypeInformation -Encoding UTF8
  • The example below exports the list of all DL’s and members to C:\export\All-Distribution-Group-Members.csv
  • The exported .csv will display the data in the following format
Updated on April 2, 2019

Was this article helpful?

Related Articles

Leave a Comment