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.

Windows PowerShell

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

 Copied
Get-DistributionGroupMember -Identity "Brand Awareness Campaign Team" | Export -CSV "D:\DGList.csv"
Click to copy entire script

ADManager Plus

To get distribution group members report and export to CSV,

  • Launch Group Members report from Group Reports under Office 365 tab.
  • Select the desired Office 365 tenant, enter the name of the desired group click Generate. Choose CSV from Export as option.
  • You can also get this report for multiple groups; just enter the group names separated by a comma.

Screenshot

Distribution Group Members Report in ADManager Plus

» Start 30-day Free Trial

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.
  • Embark on your script-free AD management, reporting, and automation journey with ADManager Plus.
  •  
     
  • By clicking 'Start your free trial now', you agree to processing of personal data according to the Privacy Policy.
  • Thanks
  • Your download should begin automatically in 15 seconds. If not, click here to download manually.

Related Powershell How-to Guides:

The one-stop solution toActive Directory Management and Reporting

Email Download Link