March 23, 2019

Export Office 365 Dynamic Distribution Group Members to CSV

by Kathy Cooper

4 min read

No Comments

What is Office 365 Dynamic Distribution Group?

Most people aware of Distribution Lists, but the Dynamic Distribution Group has several benefits over traditional distribution lists. In Office 365 environment, a Dynamic Distribution Group (DDL) is used to expedite the mass sending of email messages and other information within an organization based on some defined rules or conditions.

Dynamic Distribution Groups membership is calculated based on specific recipient filters and conditions rather than a defined set of recipients. For example, you can build a Dynamic Distribution Group that is intended to include all recipients in a particular state or department or title, etc. When an email is sent to that group, the membership would be built based on recipient filter and then delivered to its members.

Dynamic Distribution Group Members

The primary advantage of using the Dynamic Distribution Group is that membership is derived automatically from the recipient filter. There is no need to add members manually to the group. Since there is not a defined static list of members, it’s slightly more difficult to get a list of all members. Due to that, the size of the group is unstable (it may grow or shrink).

There may be an occasion when we need to find out who are the members of the Dynamic Distribution Group and how many.

If you want to export Distribution Group membership, you can refer our Export Office 365 Distribution Group Members to CSV blog.

How to view Dynamic Distribution Group Members?

You can view the members of a DDL in EAC, but it has limitations, such as the need to click each group to see its members. This can become tiresome, especially when dealing with multiple dynamic distribution groups. In such cases, you can use PowerShell cmdlets like Get-DynamicDistributionGroup and Get-Recipient to get members of the Dynamic Distribution Groups. We have built the PowerShell script to list DDL with its members and other necessary information. This script significantly simplifies the management of Dynamic Distribution Lists.

Script Highlights:

  • The script can be executed with MFA enabled account.
  • Allows you to filter the output based on group size (i.e., Members count).
  • You can choose to either “export members of all Dynamic Distribution Groups” or pass an input file to get members of specific groups alone.
  • Output can be filtered to list Empty group. i.e., DDL without members
  • Exports the result to CSV
  • You can get members count based on Member Type such as user mailbox, Group mailbox, shared mailbox, contact, etc
  • Above all, script stores output in nicely formatted 2 CSV files. One with detailed information and another with summary information.
  • Dynamic Distribution Group – Summary Report : Following are the columns available
    • Group Display Name, 
    • Primary SMTP Address,
    • Group Alias,
    • Group Manager,
    • Hidden From Address List,
    • Group Members Count,
    • Members Count by Type
  • Dynamic Distribution Group – Detailed Members Report : Following are the columns available
    • Group Display Name, 
    • Primary SMTP Address,
    • Group Alias,
    • Group Manager,
    • Group Members Count,
    • Group Members, 
    • Member Email Address
    • Member Type

How can I Execute a ‘DDL Membership Report’ Script?

You can choose any of the below methods based on your requirement.

Method 1: To execute the script with MFA enabled account,

Method 2: To execute the script with non-MFA account,

Method 3: To pass the credentials as parameters (Scheduler-friendly).

If the admin account has MFA, you must disable MFA using Conditional Access Policy to make this script work. Else, you can adopt certificate based authentication to connect to Exchange Online PowerShell.

Script Output:

The exported report will look similar to below screenshots.

Dynamic Distribution Group – Summary Report:

Dynamic distribution group members report

Dynamic Distribution Group – Detailed Members Report:

Get dynamic distribution group members

How to filter the output?

You can use params to filter the output to get the desired result or simply execute the script to list all Dynamic Distribution Group and its members.

Export Members from a List of Dynamic Distribution Groups in input file

To get members of specific Dynamic Distribution Groups, pass an input file using -GroupNamesFile.

The group names CSV File must follow the format below: Display name of groups separated by new line without header.

Dynamic distribution group membership-inputfile

Export Dynamic Distribution Group Members that has more than ‘N’ Members

To filter result based on group members count, you can use MinGroupMembersCount param. i.e., You can get groups that have more than the specified number of members.

Above script reports all Dynamic Distribution Lists that has more than 50 members.

Export Empty Dynamic Distribution Groups

To get an empty Dynamic Distribution Group (i.e., Dynamic Distribution Group without members), execute the script with -IsEmpty param.

Using this filter, you can delete unused Dynamic Distribution List available in your tenant.

How can I Schedule this script?

You can schedule this script in task scheduler by explicitly mentioning the credential.

To know more about scheduling Powershell script, refer our blog: Schedule PowerShell script using Task Scheduler.

I hope this post was helpful. If you modify the script and use it for other use cases, then please leave your idea in the comment section and help more admins.

Share article