The Network Manager at Westminster School presents solutions to sticky problems...

Friday 21 August 2015

Remote Routing Address Woes - A Hybrid Exchange Problem

So you have to have the Hybrid Exchange. You are better off with either all in, or all out, but Hybrid is an option. There are some problems with Hybrid and that's when you get the Remote Routing Address wrong. How do you change it?

You create a user in the On Premises Active Directory, and then you let it sync to the cloud. You set up your licensing and then you run Enable-RemoteMailbox which includes the -RemoteRoutingAddress option. Of course, if you get it wrong...

Exchange Online will not let you change it. Exchange On Premises refuses to recognize the option in Set-RemoteMailbox. So... you now have to delete the RemoteMailbax, which in turn deletes the user account, you have to... 

Well, no. See, the value is stored in AD under the value targetAddress. Change this and your problems are over.

Added a lot of users in one go? Have a lot to change? No fear:

Create a CSV file with two headings: email, remote

Under email add "userprincipalname=username@domain" This is your filter.
Under remote add "SMTP:username@domain.onmicrosoft.com" being the correct remote routing address in the correct format for the targetAddress value. Now, turn to powershell (run as administrator, of course):

Import-Module ActiveDirectory
new-psdrive -PSProvider activedirectory -Name Users -Root "AD:\OU=Users,DC=domain,DC=com"
Set-Location Users:
$users = import-csv c:\temp\users.csv
foreach ($user in $users) {
write-host $user.email
Set-ItemProperty -filter $user.email -path * -Name targetAddress -Value $user.remote
}

The write-host line is for comfort only. The Set-ItemProperty does not report back when run in a script.

No comments:

Post a Comment