How to get distribution group members using PowerShell from Office 365
This article explains the procedure to use PowerShell to list distribution group members in Exchange Online or Office 365, and export them to CSV using the Get-DistributionGroupMembers cmdlet. It also compares it with steps needed to accomplish it with ADManager Plus, a unified Active Directory, Office 365 and Exchange management and reporting tool, to show how it helps get distribution groups list and export it easily.
Steps to use PowerShell to get distribution groups list members.
- Ensure you have the necessary permissions to generate this report.
- Get the value for Identity parameter, which is name of the distribution group whose members you wish to list and export to CSV.
- Create the script using Get-DistributionGroupMembers cmdlet
- Execute the script from PowerShell window.
A sample script to list distribution group members in Office 365 and export list using PowerShell
Click to copy entire script
Get-DistributionGroupMember -Identity "Brand Awareness Campaign Team" | Export -CSV "D:\DGList.csv"
The PowerShell cmdlet Get-DistributionGroupMember will all members of the group Brand Awareness Campaign Team and export the distribution list members to CSV.
Limitations of using PowerShell to get distribution group members using PowerShell in Office 365 or Exchange Online.
- You will not be able to generate this report using PowerShell if you do not have sufficient permissions and Exchange PowerShell. With ADManager Plus, users privileges in native AD or Exchange doesn't have to be elevated, and they can be allowed to do this operation only in specific OUs or domains.
- There is no flexibility to include or exclude the Nested groups and their members while generating distribution list members report using this script. A new script has to be created to achieve this. ADManager Plus offer the flexibility to include or exclude nested groups from the report.
- To export this report to any other format instead of CSV, you will have to modify the script. With ADManager Plus though, it is offered as a built-in option that's available by default.
- You must know how to trigger the scripts from the PowerShell window. ADManager Plus is purely GUI-based, allowing you to perform all management and reporting actions with just mouse clicks from its web-based console.
- Even a misplaced hyphen, a typo in the LDAP names or lack of sufficient permission to configure any of the attributes used in the script will lead to errors. As all actions in ADManager Plus are GUI-driven, there is no need to write scripts, eliminating the chances of errors.
Single-window mailbox management and reporting for Exchange and Office 365 with ADManager Plus.
Get 30-day free trial.