0

Automating Enable-Remote Mailbox

While operating in an Exchange hybrid model, users expect to see a consistent GAL no matter if they or other people to be contacted are on-premises or in Exchange Online.  In order for the Exchange on-premises servers to be able to build up a complete GAL there needs to be at least some mailbox information added to the AD user object.  If Exchange Online mailboxes are added by simply assigning an Exchange Online license directly to the synchronised Azure AD object, then the required attributes are not added to the on-premises user object.

If all the mailboxes are in Exchange Online, then this may not be an issue.  However, for those customers that are still have some mailboxes on-premises this may be an issue they need to manage for some time to come!

Depending on the version of Exchange that have on the premises, the UI will differ, however PowerShell remains constant.

 

Enabling Remote Mailbox For A Single User

The PowerShell command to enable a remote mailbox for a single user is a single line of code.  TechNet Docs covers this on this page.  The below is one of the examples from there.

 

 

 Enable-RemoteMailbox "Kim Akers" -RemoteRoutingAddress "kima@contoso.mail.onmicrosoft.com"

 

 

Optionally, if you also need that person to have an Online Archive mailbox as well, the process is very similar to on-premises Exchange - just add the Archive parameter.

 

 

 Enable-RemoteMailbox "Kim Akers" -Archive

 

 

Note that we need to specify the full RemoteRoutingAddress.  There is no %G or %s like you would find in an Email Address policy.

 

Automating Enabling Remote Mailbox

If we need to enable multiple people for a remote mailbox, having to fully specify each RemoteRoutingAddress is something that we need to factor in.

Please consider the below sample code, and you must consider how this is to be best implemented in your environment.  Your mileage may vary...

 

The below example demonstrates pulling in the UPN prefix and leveraging the first element in a dynamically created array which is used as the RemoteRoutingAddress in this case.

Note that the initial collection is tailored to suit, creating a collection of one in this case for initial testing.  This can be easily expanded to suite needs and requirements.

 

 $Users = Get-User -Identity ssmith@Tailspintoys.ca
 $users | % {Enable-RemoteMailbox -Identity $_ -RemoteRoutingAddress((($_.UserPrincipalName.split("@")[0])) +"@tailspintoyscanada.mail.onmicrosoft.com")}

 

 

Automating Enable-Remote Mailbox

 

The above can be adjusted as necessary, and the Archive option added if needed.  For more details and examples on the archive aspect, please see this post on enabling remote archives.

 

Cheers,

Rhoderick

Rhoderick Milne [MSFT]

Leave a Reply

Your email address will not be published. Required fields are marked *