EmailAddressPolicy for Exchange 2010 /hosting [One organization, multiple primary domains]



If you are running Exchange 2010 in hosting mode then you will probably run across a client that wants everyone to be in the same organization so they can see everyone in the GAL, but also wants some users to have a primary domain that is different than others.
After messing with the ConditionalCompany and other Conditional fields I believe I found a better way to accomplish this without even having to mess with anything in Active Directory Users & Computers.
So the first thing you want to do is add the extra domain as an accepted domain:
- New-AcceptedDomain -Name domain2.net -DomainName domain2.net-Organization "My First Org"
Next you will want to create your email address policy. Instead of setting the conditional fields we are just going to set the RecipientFilter to something custom. Using the UserPrincipalName will allow us to apply this policy based on their UPN (also the accepted domain you just added).
- New-EmailAddressPolicy -Organization ORGANIZATIONNAME -NameDOMAINNAME -EnabledEmailAddressTemplate SMTP:@NEWDOMAIN -RecipientFilter {((UserPrincipalName -like '*@NEWDOMAIN') -and (Alias -ne $null))}
Completed Example:
- New-EmailAddressPolicy -Organization "My First Org" -Namedomain2.net -EnabledEmailAddressTemplates SMTP:@domain2.net -RecipientFilter {((UserPrincipalName -like '*@domain2.net') -and (Alias -ne $null))}
This policy will only apply to the users that were created with the domain2.net accepted domain.
Due to a weird issue with Exchange 2010 /hosting the Update-EmailAddressPolicy does not seem to work. If you want to apply this after the fact you have to use the Set-Mailbox command. It seems to update when you do that.
Example:
- Get-Mailbox -Organization "My First Org" | Set-Mailbox
There are some variables you can use when setting your EnabledEmailAddressTemplates:
- %g [First Name / Given name]
- %s [Last Name / Surname]
- %i [Middle Initial]
- %m [Exchange Alias]
- %d [Display Name]
The cool thing that you can do is specify a number which represents the amount of characters you want to include from the first name or last name. So lets take the user: Jacob Dixon
- %1g%s@domain2.net [jdixon@domain2.net]
- %s%1g@domain2.net [dixonj@domain2.net]
- %2g%s@domain2.net [jadixon@domain2.net]
So if you wanted the users first initial and last name, and also last name plus the first initial to be automatically applied you would have to set your email address policy like this: [Keep in mind using a capitalized SMTP specifies the primary domain and uses lower case smtp specifies secondary or extra domains. You can only use one SMTP]
- New-EmailAddressPolicy -Organization "My First Org" -Namedomain2.net -EnabledEmailAddressTemplatesSMTP:%1g%s@domain2.net,smtp:%s%1g@domain2.net -RecipientFilter {((UserPrincipalName -like '*@domain2.net') -and (Alias -ne $null))}
- Add new comment
- 2 comments
Thanks
Thanks a LOT.. was struggling for this frm last few days .. Thanks BOSS>
Good.. infact great article/ help
Happiness ALways...
Thanks, i spent ages trying
Thanks, i spent ages trying to run the update-emailaddresspolicy command and even if you pipe it from a get it still doesnt work.
Get-Mailbox -Organization "My First Org" | Set-Mailbox works a treat and you can test it by running
Get-Mailbox -Organization "My Org" | fl emailaddresses
Post new comment