Exchange 2007 Email Address Policy - distribution lists & mailboxes

We are set to finish our migration of several email domains over to our Exchange 2007 environment. One of the last issues to migrate across is the Exchange 2003 Recipient Update Policies, into the Exchange 2007 Email Address Policies.

Our current e2k3 RUP is a fine-tuned LDAP query:

(mailnickname=*)
(|(extensionattribute3=EXAMPLE*)(department=EXAMPLE*))
(|(objectCategory=group)(&(objectCategory=person)(objectClass=user)))

Where is Example is populate in the Department field on mailboxes and Custom Attribute 3 on DLs. With 2007, to build a similar recipient filter, you need to use OPath. OPath uses a Powershell filtering, less LDAP. For example:

(CustomAttribute3 -like "EXAMPLE*")

That part was fairly easy. What I got hung up on was the format to query distribution lists.

$recDept = "EXAMPLE"
$recFilter = $recDept+"*"
$TemplateSMTP = "SMTP:%g.%s@Example.com"

$recipientFilter = "(((RecipientType -eq 'mailUniversalDistributionGroup' -or RecipientType -eq 'mailUniversalSecurityGroup' -or RecipientType -eq 'mailNonUniversalGroup' -or RecipientType -eq 'DynamicDistributionGroup') -and customAttribute3 -like '$recFilter') -or (RecipientType -eq 'UserMailbox' -and Department -like '$recFilter'))"

New-EmailAddressPolicy -Name "Example.com Address Policy" -EnabledPrimarySMTPAddressTemplate $TemplateSMTP  -RecipientFilter $RecipientFilter

The policy created when New-EmailAddressPolicy is ran, will only apply the SMTP address to mailboxes (with 'Example' in the department) and any mail-enabled group (with 'Example' in Custom Attribute3).

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <blockquote> <center> <hr> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal6>, <html>, <java>, <javascript>, <php>, <posh>.

More information about formatting options