Skip to content

Instantly share code, notes, and snippets.

@Apoc70
Last active October 25, 2021 07:00
Show Gist options
  • Save Apoc70/39a22f4e3c25ead001938e5b0f8ee2d7 to your computer and use it in GitHub Desktop.
Save Apoc70/39a22f4e3c25ead001938e5b0f8ee2d7 to your computer and use it in GitHub Desktop.
Update UPN suffix for all users in preparation Azure AD Connect
# Update the User Principal Name for all User Objects
$CustomDomain = "mcsmemail.de"
# Add custom domain as suffix first
Get-ADForest | Set-ADForest -UPNSuffixes @{add=$CustomDomain}
# Update all user objects
Get-ADUser -Filter * -Properties SamAccountName | ForEach-Object { Set-ADUser $_ -UserPrincipalName ($_.SamAccountName + "@$($CustomDomain)" )}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment