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

It will try to add the proxy address 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 -


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.