Wednesday 25 November 2009

Creating a dynamic distribution group with advanced filtering on Exchange 2007

In Exchange 2003, it was very easy to build a dynamic distribution group with the GUI. Exchange 2007 is much more limited unless you use Powershell. I needed to create a dynamic distribution group targeting a particular server, as long as the user mailboxes didn't have a forwarding address. The reason for wanting to avoid the mailboxes with forwarding addresses is we still have Quest's Exchange Migration Wizard creating forwarding details for users on the legacy Exchange system.

The process is a two part process:
  • Create the dynamic distribution group
  • Set the filter criteria for the distribution group
To create the dynamic user, type the following all on one line in the Exchange Powershell console (don't type in the bold italic comments):
New-DynamicDistributionGroup 'The applett
-Name "Group name" 'What the group should be called
-IncludedRecipients MailboxUsers 'Just include users with mailboxes
-OrganizationalUnit "domain.com/ou1/ou2" 'Where to create the dynamic distribution group
e.g. New-DynamicDistributionGroup -Name "Group name" -IncludedRecipients MailboxUsers -OrganizationalUnit "domain.com/ou1/ou2"

To set the filter:
Set-DynamicDistributionGroup 'The applett
"Group Name" 'What the group is called
-Notes "Blah blah blah" 'Description
-RecipientFilter {ServerName -eq 'ServerX' -and ForwardingAddress -eq $Null} 'Mailbox exists on ServerX and the forwarding address is empty
-RecipientContainer "domain.com/ou1/ou2" 'What container the recipients are under - It can just be the domain
e.g. Set-DynamicDistributionGroup "Group Name" -Notes "Blah blah blah" -RecipientFilter {ServerName -eq 'ServerX' -and ForwardingAddress -eq $Null} -RecipientContainer "domain.com/ou1/ou2"
Once set with Powershell, they can be viewed by the GUI, but not changed. Beware that the preview button does not take account of the -RecipientContainer parameter - It will show you all users in the domain that match.

Inspiration from:
DanW

No comments:

Post a Comment