Exchange 2007 Dynamic Distribution Groups with Custom Filters

Exchange 2007

Recently I was experimenting with Exchange 2007 Dynamic Distribution Groups for a client. I have the Active Directory profiles of each mailbox-enabled user filled out so that I can dynamically create and set their Outlook profiles automatically. I wanted to use some of this information that I already store about each user to create distribution groups on the fly so that I don’t have to actively maintain group membership.

Specifically, I wanted to use the Office and Description field of their Active Directory profile to include them in a distribution group. For instance, I have the following basic information stored in Active Directory for each user:

User A
Description: Dallas User
Office: Corporate Office

User B
Description: Dallas User
North Dallas Field Office

User C
Description: Houston User
Office: Houston Office

If I want to maintain distribution groups in Exchange for each geographical area as well as each individual office, that is pretty easy in Exchange 2007.  You just create a new Dynamic Distribution Group.  However, the difficulty comes when you want to use an Active Directory profile field that is not built in the Exchange Management Console GUI.

Executing the following command in the Exchange Management Shell will create a new Dynamic Distribution Group that selects every mailbox-enabled user with a Description field set to “Dallas User”:

New-DynamicDistributionGroup -Name “GroupNameHere” -OrganizationalUnit “domain.local/OUNameHere” -RecipientFilter { ((RecipientType -eq ‘UserMailbox’) -or (RecipientType -eq ‘MailContact’) -or (RecipientType -eq ‘Contact)) -and (Description -eq ‘Dallas User’) }

Leave a Reply

Your email address will not be published. Required fields are marked *