Friday 12 September 2008

Exchange 2007, DDL's and OPATH Filters

Well well well.

MS Have done another Grand job implementing Dynamic Distribution Lists. I mean OK, I can cope with having to use the PS to create "fancy" one's. I mean that's what the PS is for, doing more "hardcore" admin. But for Jeebus sake, make it work.

My task? Customer wants to create a DDL for each Storage Group (and/or Database) he has, so he can send email out to the list when he has any Database Maintenance to do. Simple enough surely?

get-mailboxdatabase -StorageGroup STORAGEGROUPNAME | % { New-DynamicDistributionGroup "DDG-$($_.Name)" -RecipientFilter "Database -eq '$($_.Identity.DistinguishedName)'" }

Fabulous. Creates a DDL from the Database in the Storage Group, and adds all users to it.

Almost.

Preview it in EMC.

Cannot convert value "EXCHTEST\First Storage Group\Mailbox Database" to type "Microsoft.Exchange.Data.Directory.ADObjectId". Error: "The string "EXCHTEST\First Storage Group\Mailbox Database" does not represent a valid distinguished name."

But wait, I told Exchange to use the "Identity.DistinguishedName". Why is it now talking "shortened" language to me?

Looks like Exchange translates this, as its not able to store the OPATH filter directly. Well we can fix that.

Dig out ADSI edit. Locate your DDL you just created (Users typically). Modify it. Find the "msExchQueryFilter" attribute.

(Database -eq 'EXCHTEST\First Storage Group\Mailbox Database' -and -not(Name -like 'SystemMailbox{*') -and -not(Name -like 'CAS_{*'))

Thats not right.

Fire up a powershell, get-mailboxdatabase | fl.

Copy (and clean up with notepad or something similar) the Distinguished name, it should look something like this;

CN=Mailbox Database,CN=First Storage Group,CN=InformationStore,CN=EXCHTEST,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=exchangetest,DC=local


Now copy it, flip back into ADSI edit, and change mcExchQueryFilter like so;

(Database -eq 'CN=Mailbox Database,CN=First Storage Group,CN=InformationStore,CN=EXCHTEST,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=exchangetest,DC=local' -and -not(Name -like 'SystemMailbox{*') -and -not(Name -like 'CAS_{*'))

Preview it (again) and voila! :)

No comments: