News We Recently Launched AD Migrator and AD Reporter.

Export All Distribution List Members from Office 365 With Membership

  author
Written By Mohit Jha
Anuraag Singh
Approved By Anuraag Singh  
Published On July 9th, 2024
Reading Time 6 Minutes Reading

Office 365 is an efficient and reliable productivity suite that offers cloud services and tools for business, education, and personal usage. One of the features introduced by O365 is called ‘Distribution Groups’. With the assistance of the Exchange Online distribution group, the sharing of resources has become simpler among different members and users. In this article discussed how to export distribution list members from Office 365 via / using Powershell Command.

Table of Content

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. Let’s discuss the real-life scenario where admins face different situations and why they need to export the list of user accounts from a group. 

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 quickly and simply.

“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.”

To know which member belongs to which distribution list has always been a tedious task. The same is the case with Office 365. This mystery can still be trickier to solve in Exchange Online. The post deals with a sure-shot solution to search and transfer distribution members in O365. We are utilizing Exchange Admin Center and PowerShell commands.

 

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

Microsoft offers two ways using which admins can Export Distribution List Members, let’s discuss both of them step by step in the coming section:

Method 1. Export Distribution List Members from Office 365 Using EAC

Admins who are not very aware of PowerShell technicalities can prefer this method to export a list of users from the distribution list.

Step 1. Use your admin credentials to sign in to your Microsoft 365 account and navigate to the Exchange Admin Center by clicking on the Exchnage.

01-opening-exchange-admin-center
Step 2. Under the Recipients category navigate to the Groups.

02-navigating-distribution-list
Step 3. Click on the Distribution list option from the navigation menu and click on the Export button.

03-clicking-export
Step 4. Click on the Export groups in this list option to export specific group members.

04-exporting-distribution-list-members-from-office-365
Step 5. A small popup window will option with the estimated time it might take. Then click on the Continue button.

05-exporting-active-groups
Then it will export the members from the distribution group to a CSV file.

Method 2. Use PowerShell to Export Distribution List Members from Office 365

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 the 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 lists using the Get-DistributionGroup command and then, extract its members by iteration of every group using the 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 members. Moreover, it generally happens with Office 365 users. 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

Q. What is the use of obtaining an Office 365 distribution list?

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

Q. 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.

Q. 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.

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

With the help of the above tool, users can get rid of all the issues that occur during the usage of the PowerShell command and securely export distribution group as well as all its members.

  author

By Mohit Jha

Mohit is a Microsoft Certified expert known for his cloud migration, cyber security, and digital forensics expertise. He specializes in Microsoft 365, Exchange Server, and Azure AD migration, ensuring seamless transitions for organizations worldwide. His multifaceted role as a meticulous tech writer, diligent researcher, and astute editor underscores his commitment to delivering cutting-edge digital forensics and cloud migration strategies.