Wednesday, November 25, 2015

UPN Normalization Phase II

Overview


NOTE: I wrote this in early 2014 however I did not publish it until now.

This is a followup to my earlier entry about normalizing the UPN for moving to Office365. This entry covers Phase II which changes the prefix of the UPN, whereas Phase I was to fix the suffix domain of the UPN.

This script will walk AD and change the prefix from whatever it is now to a standard. It looks at the primary SMTP address attribute and uses that as the source to set the UPN. This way the UPN and primary SMTP match best they can. In my environment we do have several people who instead of having @mycompany.com they have @mycompany.com.countrycode as their email domain. This pulls just the prefix from that attribute.

Solution


You will need to modify lines 2, 12, 29, and 30.

Line 2 is a limit to how many changes per run to make. I would run the script every day and let it change 5000 at a time. During initial test runs I was doing about 100 at a time.

Line 12 will need the LDAP query updated for your domain.

Line 28 and 29 just need @mycompany.com to be set to your domain from Phase I.

You can also comment out line 36 to do a test run.

When ran, it will spit out a log file in the scripts directory stating what it did as shown below.

 Updating [email protected] to [email protected]  
 Updating [email protected] to [email protected]  
 Updating johno'[email protected] to [email protected]  


Download

This script is provided as-is, no warranty is provided or implied.The author is NOT responsible for any damages or data loss that may occur through the use of this script.  Always test, test, test before rolling anything into a production environment.

You can find Cory's Phase II script here


-Kevin Fason

No comments:

Post a Comment