Exchange: List all members for ‘Dynamic Distribution Group’


Since Dynamic Distribution Group lists its members by running the query (to Get-Recipient command) whenever someone sends email to this DL. But how do we troubleshoot if a user is not receiving email from this DL. Why would this user left out? Exchange 2010 onwards Microsoft provided PowerShell is the only way to check the members of Dynamic DL. I am going to explain how to do it?

We are going to use the following commands:

Get-DynamicDistributionGroup and Get-Recipient.

First get the dynamic DL named DL-NorthAmerica and assigned to variable $dl.

$dl = Get-DynamicDistributionGroup “DL-NorthAmerica”

Next run the query and list the recipients and assigned to a variable $allr

$allr = Get-Recipient -RecipientPreviewFilter $dl.RecipientFilter -OrganizationalUnit $dl.RecipientContainer –ResultSize Unlimited

List all the recipients with any other information you want.

$allr | Select-Object Name,PrimarySmtpAddress,Title,Department,city

If you want you can save the results to a CSV file.

$allr | Select-Object Name,PrimarySmtpAddress,Title,Department,city | Export-Csv -Path “$pwd\ShoreTel-GlobalMembers.csv” –NoTypeInformation

Any questions, leave me  reply, will respond.

Advertisements

7 thoughts on “Exchange: List all members for ‘Dynamic Distribution Group’

  1. hi Anand, This was very good article. However, I want to export members from 43 Dynamic distribution group into separate CSV files 43 csv files). Is it possible?

  2. Absolutely, you can. Create a text file and type the first row as Name and type all of your 43 DL Names one for each line. Save the text file as DynamicDLList.csv. Copy past the script below to the same location and Execute the script in PowerShell after connecting to Exchange (or Exchange Online). It will create 43 CSV files with the member list.

    $DLs = Import-Csv -Path .\DynamicDLList.csv

    foreach($DL in $DLs)
    {
    $dl = Get-DynamicDistributionGroup $DL.Name
    $allr = Get-Recipient -RecipientPreviewFilter $dl.RecipientFilter -OrganizationalUnit $dl.RecipientContainer –ResultSize Unlimited
    $allr | Select-Object Name,PrimarySmtpAddress,Title,Department,city | Export-Csv -Path “.\$($DL.Name).csv” –NoTypeInformation
    }

  3. Very helpful! Any hints on how I would adjust the above script to export those 43 dynamic distribution lists into one single workbook?

    We have a main “All Employees” distribution list which contains 10 sub distribution lists for each office. Those sub distribution lists have a dynamic distribution list as their source. Assuming it isn’t easy to loop through the main distribution list, for all nested members, the next best thing would be for me to add the 10 dynamic distribution lists for each office to the DynamicDisctibutionList.csv and then export them all to the same workbook.

    1. Rodriguez, Here is how you export all 43 DDL members in to one CSV file. I have modified to store the members of each DL in “DynamicDLList.csv” to “All-Users-from-all-DDLs.csv” file with -append option.

      $DLs = Import-Csv -Path .\DynamicDLList.csv
      foreach($DL in $DLs)
      {
      $dl = Get-DynamicDistributionGroup $DL.Name
      $allr = Get-Recipient -RecipientPreviewFilter $dl.RecipientFilter -OrganizationalUnit $dl.RecipientContainer –ResultSize Unlimited
      $allr | Select-Object Name,PrimarySmtpAddress,Title,Department,city | Export-Csv -Path .\All-Users-from-all-DDLs.csv –NoTypeInformation -Append
      }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s