exchange-2007-shell-logo In some companies different departments or branch offices require different primary SMTP addresses.  You can configure these for users with Email Address Policies.  In this example the company wants all users to have an @company.com address, but each branch office’s users have a primary email address representing that branch.

First we must make sure each of the domains is included as an Accepted Domain, using the New-AcceptedDomain cmdlet.

[PS] C:\>New-AcceptedDomain -Name 'Sydney' -DomainName 'sydney.company.com'

Name                           DomainName                     DomainTy Default
                                                              pe
----                           ----------                     -------- -------
Sydney                         sydney.company.com             Autho... False


[PS] C:\>New-AcceptedDomain -Name 'Brisbane' -DomainName 'brisbane.company.com'
-DomainType Authoritative

Name                           DomainName                     DomainTy Default
                                                              pe
----                           ----------                     -------- -------
Brisbane                       brisbane.company.com           Autho... False


[PS] C:\>New-AcceptedDomain -Name 'Melbourne' -DomainName 'melbourne.company.com
' -DomainType Authoritative

Name                           DomainName                     DomainTy Default
                                                              pe
----                           ----------                     -------- -------
Melbourne                      melbourne.company.com          Autho... False


[PS] C:\>New-AcceptedDomain 'Company.com' -DomainName 'company.com' -DomainType
Authoritative

Name                           DomainName                     DomainTy Default
                                                              pe
----                           ----------                     -------- -------
Company.com                    company.com                    Autho... False

Then we can configure the Email Address Policies using the New-EmailAddressPolicy cmdlet.  In this example I am using the “Office” user attribute to filter recipients.

[PS] C:\>New-EmailAddressPolicy -Name 'Sydney' -RecipientFilter {(Office -eq 'Sy
dney')} -EnabledEmailAddressTemplates 'SMTP:%g.%s@sydney.company.com','smtp:%g.%
s@company.com'

Name                       Priority                   RecipientFilter
----                       --------                   ---------------
Sydney                     1                          Office -eq 'Sydney'


[PS] C:\>New-EmailAddressPolicy -Name 'Brisbane' -RecipientFilter {(Office -eq '
Brisbane')} -EnabledEmailAddressTemplates 'SMTP:%g.%s@brisbane.company.com','smt
p:%g.%s@company.com'

Name                       Priority                   RecipientFilter
----                       --------                   ---------------
Brisbane                   2                          Office -eq 'Brisbane'


[PS] C:\>New-EmailAddressPolicy -Name 'Melbourne' -RecipientFilter {(Office -eq
'Melbourne')} -EnabledEmailAddressTemplates 'SMTP:%g.%s@melbourne.company.com','
smtp:%g.%s@company.com'

Name                       Priority                   RecipientFilter
----                       --------                   ---------------
Melbourne                  3                          Office -eq 'Melbourne'

Here is the result for a recipient who matches the filter for the Sydney policy.

[PS] C:\>Get-Recipient 'Peter Grover' | fl Office,Emailaddresses


Office         : Sydney
EmailAddresses : {smtp:Peter.Grover@company.com, SMTP:Peter.Grover@
sydney.company.com}

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. Sandeep K M

    Can I create templeate like
    -EnabledEmailAddressTemplates ‘SMTP:%g.%s.partner@brisbane.company.com’ ?
    or -EnabledEmailAddressTemplates ‘SMTP:%g.%s.vendor@brisbane.company.com’

  2. Peter Nørredal

    Hi Paul
    Thanks for your reply

    hmm, sounds odd if this senario doesn´t Work.(I surely hope it does, somehow)

    Because next step for me in this is creating Linked mailboxes” which also should rely on OU´s in a different domain+forest, – or in general People that are not located Intra-forest … Or am I missing something here ??

    Do you know about a forum/good website where I might get help /confimation regarding the above ?

    Thanks

  3. Peter Nørredal

    Hi Paul
    I´m trying to create an email addresse policy from powershell, for users located on a different domain (Trust between AD forests) – from my mailbox server, located on my Hosting.local domain.

    I´m connected to the other forest, from this command:
    Get-ADOrganizationalUnit -Identity “OU=$CustomerName,OU=customers,DC=Domain,DC=local” –Server ‘DC01.domain.local’| FL

    (with Customername = Test.dk)
    No issues here 🙂

    BUT, when I try to create a new email address policy, pointing to the OU where the users are located on the domain: “Domain.local”, I get this error:

    ObjectNotFound: (OU=test.dk,OU=Customers,DC=Domain,DC=local:ADOrganizationalUnit) [Get-ADOrganizationalUnit], ADIdentityNotFoundException

    (BUT, the OU is there !!)

    I´m running this command from powershell:

    $CustomerName = Read-Host “New E-mail Domain for new customer”

    Import-Module activedirectory
    Get-PSDrive –Name Domain –PSProvider ActiveDirectory –Server ‘DC01.domain.local’ –credential (Get-Credential ‘domainadministrator’) –root ‘//RootDSE/’

    New-EmailAddressPolicy -Name $CustomerName -RecipientContainer “domain.local/customers/$CustomerName” -IncludedRecipients ‘AllRecipients’ -ConditionalCustomAttribute1 $CustomerName -Priority ‘1’ -EnabledEmailAddressTemplates SMTP:%2g%1s@$AcceptedEmailDomain

    Hope you can help me
    Best regards
    Peter

    1. Avatar photo
      Paul Cunningham

      I’ve never tried that scenario. Perhaps it is just a limitation that -RecipientContainer only works intra-forest.

Leave a Reply