Over the weekend, I successfully got our AD to sync with Azure AD and Office 365. Things were going great, but for some reason the accounts that it synced defaulted to a @ourorganization.onmicrosoft.com address. I was able to resolve this through PowerShell by using the following command (wrapped for readability):
Get-MsolUser -all | Where { -Not $_.UserPrincipalName.ToLower().StartsWith(“admin@”) }
| ForEach { Set-MsolUserPrincipalName -ObjectId $_.ObjectId -NewUserPrincipalName
($_.UserPrincipalName.Split(“@”)[0] + “@ourorganization.net”) }
Things look great as far as user accounts are going, BUT I have inadvertently created a small problem. When the above cmdlet was renaming accounts, it also renamed the Directory Sync account somehow, and now my directory isn’t syncing.
DirSync is still looking for "syncaccount@ourorganization.onmicrosoft.com"
In the Active Users portal, the account is now listed as "syncaccount@ourorganization.net"
When I try to manually change that back in the Office Portal or Azure, it blocks out the save button. When I try to change it in PowerShell with:
Get-MsolUser -Userprincipalname SyncAccount@ourorganization.net
| set-msolUser -UserPrincipalName SyncAccount@ourorganization.onmicrosoft.com
It throws an exception because it is “Not Settable”
I've also tried running the Azure AD Connect utility again to try and force a sync. The utility completes, but a sync never takes place.
If anyone can offer any tips to set me on my way, I’d appreciate it!