Add Office 365 Tenant Proxy Address to Exchange objects with Email Address Policy Disabled

If your organization is like a lot of them out there, you have mailbox users without the email address policy applied.  It's a pretty common practice to work around name changes, users with similar names or middle initials, or one-off primary SMTP addresses.

If that's the case, then you probably have received this error when trying to move a mailbox:

"Target mailbox doesn't have an SMTP proxy matching '<domain>.mail.onmicrosoft.com'"

We detail this message and the cause in https://support.microsoft.com/en-us/kb/2939340, but how to fix it for a bunch of people?  Fortunately, there's a script for that.

Download this script and run it from the Exchange Management Console.  You can specify a -Searchbase to scope it to a particular OU as well as target all users without the email address policy applied or only a specific user.

https://gallery.technet.microsoft.com/Add-Office-365-Tenant-93391e4c/file/145326/4/Add-TenantProxyAddress.ps1