by lunarg on March 18th 2015, at 13:38

When implementing AD/Dirsync to synchronize your on-premise AD with Office365, you may have to change the UPN-suffix to match the (e-mail) domain name used in your Office365 tenant. Most often, the local UPN-suffix would be something like domain.local, and would then have to be changed to With a lot of users, it can quickly become tedious to change this manually. Along came Powershell...

The attached script is an easy way to quickly change the UPN-suffix for all users in a particular OU. Simply adjust the parameters to match your configuration, and let it run. Note that the script runs recursively, so be careful when running this on a top-level OU, as it will cascade through all the sub-OUs.