Export Office 365 Dynamic Distribution Group Members to CSV

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?

Unfortunately, viewing members of a Dynamic Distribution Group are not feasible in the Office 365 Admin Portal. Displaying members of all Dynamic Distribution Groups is not much harder. We can use PowerShell cmdlets like Get-DynamicDistributionGroup and Get-Recipient to get members of the Dynamic Distribution Group. We have built the PowerShell script to list Dynamic Distribution Groups with its members and other necessary information. 

 

You can Download the script from TechNet Gallery

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 Type 

 

How can I execute a script with MFA?

To execute script with MFA enabled account, you need to mention -MFA switch during script execution.
To know more about how to connect exchange online PowerShell with MFA, refer our blog Connect Exchange Online PowerShell with MFA.

 

Script Output:

Script execution steps available in our  O365 users’ last logon time blog. Please refer the blog.

The exported report will look similar to below screenshots.

Dynamic Distribution Group – Summary Report:

Getting Dynamic Distribution group members

Dynamic Distribution Group – Detailed Members Report:

Dynamic Distribution group members report

 

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 with a display name of groups.

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.

 

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.