In the process of migrating our mailboxes from our on-premise Exchange servers to Office 365, we had to rewrite the mailbox enable scripts. This script keys off of our HR database, does some magic, then calls
Enable-Mailbox on Exchange 2010 servers. To update this to support creating mailboxes in Office 365, we needed to set user licenses, and use the
Enable-RemoteMailbox command in Exchange 20131.
One of the quirks we stumbled upon is a bug in the Exchange 2013 tools that didn’t allow it to identify the domain for the remote routing address. This is what we’d get:
1 2 3 4 5 6
According to the Microsoft documentation for
Enable-RemoteMailbox you should be able to specify just the sAMAccountName as an argument, the rest should be calculated.
The remote routing address doesn’t need to be specified because mail flow between the on-premises organization and the service has been configured. Using this configuration, the Enable-RemoteMailbox cmdlet automatically calculates the SMTP address of the mailbox to be used with the RemoteRoutingAddress parameter.
This apparently isn’t the case, so some tweaking was needed. We called upon
Get-ADUser to retreive the account, and fill in the rest.
As this is part of a script, the content is slightly different, but you can see how it works. We used
Get-ADUser earlier in the script to pull other user data to calculate licensing requirements, but if you’re doing this as a one off and are seeing the error then you could just as easily do this:
Hat tip goes to Steve Goodman for posting similar work, and getting me back on track.
If you are using a 2010 Exchange environment, you need a 2013 server to act as a Hybrid server to migrate users.↩