Export All Distribution List Members from Office 365 With Membership

  author
Written By Mohit Jha
Anuraag Singh
Approved By Anuraag Singh  
Published On September 23rd, 2022
Reading Time 5 Minutes Reading

Office 365 is an efficient tool in the business field that provides a complete suite of Microsoft applications online. One of the features introduced by O365 is called ‘Distribution Groups’. With the assistance of the all Exchange Online distribution group, sharing of resources have become simpler among different members and users. In this article discussed how to export distribution list members from Office 365 via / using Powershell Command.

In any company, people can create groups and add members to it. In this way, sharing of ideas and tasks is simplified to a great extent.

To know which member belongs to which distribution list has always been a tedious task. Same in the case of Office 365. This mystery can still trickier to solve in Exchange Online. The post deals with a sure-shot solution to search and transfer distribution members in O365. The approach used here is PowerShell commands.

On using the Exchange online PowerShell cmdlet Get-DistributionGroup and Get-DistributionGroupMember, users can list all the distribution groups as well as its members.

Need to Export Distribution List Members From Office 365

Consider the following queries faced by users while using Office 365:

“Hi everyone. Recently, we ran into an issue where we had to reassemble distribution lists for our organization. We just want to know what to do if something ever happens again. Please, could you help us to know what people are in what distribution group? We are using Office 365. Also, tell us any solution on how to export distribution list members from Office 365. Thanks in advance.”

Microsoft Office 365 Email Backup Utility by SysTools to get rid of all the issues in quick and simple way.

“Hi. I have a distribution list which contains around 10,000 members inside. If I run a PowerShell command, only 1000 will be shown out of them. May be I am making mistakes at some points. Please, suggest me the best way to export a list of members from the Exchange Online distribution list. Any help or leads will be greatly appreciated.”

PowerShell Command to List Office 365 User Group Membership

Users are recommended to execute the following set of commands to get a proper list regarding Office 365 distribution list members.

  • Run this command to connect with the Office 365 PowerShell module:
1. $365Logon = Get-Credential


2. $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 
https://outlook.office365.com/powershell-liveid/ -Credential $365Logon 
-Authentication Basic -AllowRedirection


3. Import-PSSession $Session

  • To list all the distribution groups, run the following cmdlet:
 Get-DistributionGroup -ResultSize Unlimited
  • To obtain a list of group members, run below command:
Get-DistributionGroupMember -Identity "" -ResultSize Unlimited

Export Group Members From One Distribution List to CSV File

The PowerShell method to get members from a given distribution list and then, export its members to a CSV file.

1. $DGName = ""


2. Get-DistributionGroupMember -Identity $DGName -ResultSize Unlimited |
 Select Name, PrimarySMTPAddress, RecipientType |


3. Export-CSV "C:\\Distribution-Group-Members.csv" -NoTypeInformation -Encoding UTF8

Users can interchange the factor with the name of their actual group.

Transfer All Distribution Groups As Well As Members to a CSV File

In this methodology, firstly users have to fetch all the distribution list using Get-DistributionGroup command and then, extract its members by iteration of every group using Get-DistributionGroupMember PowerShell command.
The cmdlet written below will export all the groups as well as members to a CSV file:

1. $Result=@()
2. $groups = Get-DistributionGroup -ResultSize Unlimited
3. $totalmbx = $groups.Count
4. $i = 1
5. $groups | ForEach-Object {
6. Write-Progress -activity "Processing $_.DisplayName" -status "$i out of $totalmbx completed"
7. $group = $_
8. Get-DistributionGroupMember -Identity $group.Name -ResultSize Unlimited | ForEach-Object {
9. $member = $_
10. $Result += New-Object PSObject -property @{
11. GroupName = $group.DisplayName
12. Member = $member.Name
13. EmailAddress = $member.PrimarySMTPAddress
14. RecipientType= $member.RecipientType
15. }}
16. $i++
17. }
18. $Result | Export-CSV "C:\\All-Distribution-Group-Members.csv" -NoTypeInformation -Encoding UTF8

Time To Wrap Up

While working in an organization, oftentimes the need arises to get an entire distribution list and its group member. Moreover, it generally happens with Office 365 users. In order to solve the problem of users, the write-up explains how to export distribution list members from Office 365 using PowerShell command. Starting from the beginning, all commands are explained in a step-by-step manner.

Commonly Asked Queries

What is the use of obtaining Office 365 distribution list ?

With the help of Office 365 distribution list user can easily understand which member is in which distribution group. When handling a large group, by taking the distribution list will also help to easily find if any important member is missing from that group or not.

How to get the distribution group and its members of MS Office 365 ?

To obtain the distribution group and its members you can use the following power shell commands “Get-DistributionGroup” and “Get-DistributionGroupMember” respectively.

Can I export Exchange Online distribution group members into CSV file format ?

Yes, once you get the list of members from the distribution group list you can export office 365 distribution group members into CSV with the help of Export-CSV cmdlet.

How can I export Office 365 distribution group as well its members securely ?

With the help of Office 365 Backup tool user can get rid of all the issues occur during the usage of power shell command and securely export distribution group as well as all its members.

  author

By Mohit Jha

Mohit is a Microsoft Certified Expert who wears multiple hats as a writer, researcher, and editor. He's really into cyber security, cloud computing, and digital forensics. These topics get him excited and push him to go beyond just his job. His big goal is to create super well-researched and carefully written articles that help readers learn important technicalities.