Dynamic Distribution Group is the Exchange Server 2010/2007 term for Query-Based Distribution Groups supported by Active Directory (and therefore Exchange Server 2003/2000) in Windows Server 2003. Unlike normal security and distribution groups, which have static membership (defined by manually adding users/recipients as members of the group), the membership of a Dynamic Distribution Group is determined every time the group receives a message. The (SMTP) Transport’s Categorizer component queries a Global Catalog for a list of recipients matching the LDAP filter defined in the group.
Windows Server 2003’s ADUC console allows you to preview recipients returned by the filter, by going to the group’s properties and clicking Preview. However, with recipient management moved to Exchange in Exchange 2007, this ability to preview is limited to groups created using Exchange’s “pre-canned” filters. If you’re using a custom recipient filter (Exchange 2007 uses OPATH filters), you can’t preview the recipients returned using the EMC.
In “Adventures with OPATH: some annoyances if you’re used to LDAP“, I showed how you can preview Dynamic Distribution Group membership using the Saved Queries feature in ADUC (the Windows 2003 version).
Later I noticed the product documentation was updated to include a way to view which recipients get picked up by the recipient filter – this is easily accomplished from the shell, using the following commands:
$Group = Get-DynamicDistributionGroup -Identity “My Dynamic Group”
This stores the Dynamic Distribution Group in a variable called $Group. Now we can use the Get-Recipient command and filter the output using the recipient filter from the variable $Group:
Get-Recipient -Filter $Group.RecipientFilter
Update: You can also shorten this to a one-liner:
Get-Recipient -Filter (Get-DynamicDistributionGroup “My Dynamic Group”).RecipientFilter
If you specify a RecipientContainer in the Dynamic Distribution Group configuration to pick recipients from a specified OU or container in Active Directory, using the above method to return recipients will not be accurate because it returns recipients from the entire domain.
View Members of a Dynamic Distribution Group doesn’t mention it at the time of writing (docs are updated regularly), but the Exchange 2007 version of this doc does have an example that uses the OrganizationalUnit parameter, which is fed (value of) the RecipientContainer property of the dynamic distribution group filter.
$MarketingDepartment = Get-DynamicDistributionGroup -Identity “Marketing Department”
Get-Recipient -RecipientPreviewFilter $MarketingDepartment.RecipientFilter -OrganizationalUnit $MarketingDepartment.RecipientContainer