How to get dynamic distribution group members using PowerShell from Exchange Online

This article explains the procedure for using PowerShell to get dynamic distribution group members from Exchange Online or Office 365, and export them using Get-DynamicDistributionGroup and Get-Recipient cmdlets. It also compares this procedure with ADManager Plus, a unified Active Directory, Office 365 and Exchange management and reporting tool, to show how the latter helps get dynamic distribution groups list and export it easily.

Windows PowerShell

Steps to use PowerShell to get dynamic distribution groups list members.

  • Ensure you have the necessary permissions to generate the dynamic distribution group members report.
  • Create the script using the Get-DynamicDistributionGroup and Get-Recipient cmdlets, and execute it in the PowerShell window.

A sample script to get dynamic distribution groups members in Office 365 and export list using PowerShell

 Copied
$FTE = Get-DynamicDistributionGroup "Branding Campaign Team"; Get-Recipient -RecipientPreviewFilter $FTE.RecipientFilter -OrganizationalUnit $FTE.RecipientContainer | Export -CSV "D:\DGList.csv"
Click to copy entire script

ADManager Plus

To get dynamic distribution group members report:

  • Launch Dynamic Distribution Group Members report from Group Reports under Office 365 tab.
  • Select the desired Office 365 tenant, and click Generate. Choose CSV from Export as option.

Screenshot

Office 365 Dynamic Distribution Group Members Report in ADManager Plus

» Start 30-day Free Trial

The PowerShell cmdlets Get-DynamicDistributionGroup and Get-Recipient will list the members of Branding Campaign Team and export the list to CSV.

Limitations of using PowerShell to get dynamic distribution group members 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.
  • You will have to use two commands, and multiple parameters to get this report. ADManager Plus offers purpose-built feature to accomplisb this, with just mouse clicks.
  • 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.
  • 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:

Email Download Link