This script will find mailboxes that are configured with EmailAddressPolicyEnabled:$false and have no "@tenant.mail.onmicrosoft.com" address and will add the SMTP routing address required for an Exchange Online Hybrid deployment.

It will try to add the proxy address prefix@tenant.mail.onmicrosoft.com for each mailbox found,
if that address is already being used, it will add a random number to the alias and will add that smtp address.

Please visit my blog for comments - ilantz.com/2013/12/22/manually-adding-a-secondary-smtp-proxy-address-for-hybrid-exchange-online-and-office-365

 

Revision History
--------------------------------------------------------------------------------
1.0     Initial release
1.1     Updated and rewritten as a script instead of a function which caused confusion
1.2     Added Logging of successful addresses being added and failures
1.3     Updated with server-side filtering to get all relevant users for better efficiency,
          an updated logging mechanism and using now the PrimarySmtpAddress prefix value for the routing address.