If you’ve ever had to deactivate and reactivate directory synchronization in Office 365, you’ve probably read the Directory Synchronization and Source of Authority page on the Office 365 site. In there is a section which talks about how it’s a best practice to backup your cloud user object data using the following command:

Get-Mailbox |select emailaddresses, name, userprincipalname, identity|export-csv -path C:\export\userlist.csv

There is a sentence in that section which states:

If you want to roll back the reactivation, Userlist.csv helps you to recover user objects to their current state. Rolling back reactivation is a manual, and potentially lengthy, process. You’ll need the help of Office 365 Support.

Based on what we know about Directory Sync and the backup script they are providing, it would seem the risk here is you lose proxyAddresses that exist in Office 365, but not in your local Active Directory. With that in mind we created this script which will import the secondary proxyAdddresses from Office 365 to the local AD should you find yourself needing to do a restore. The script does SMTP Address matching as described in this blog post.

To use the script, you’ll need to first change the backup command a bit and add the NoTypeInformation switch:

Get-Mailbox |select emailaddresses, name, userprincipalname, identity|export-csv -NoTypeInformation -path C:\export\userlist.csv

When you run the script you will be prompted to run in report mode or modify mode. After signing in, you can download the script below.

Sync Proxy Addresses from Office 365 to Active Directory Script

Was this article helpful?