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.