Skip to content

Instantly share code, notes, and snippets.

@danaugustin
Created August 14, 2018 17:42
Show Gist options
  • Save danaugustin/b7f143f9584401007f17273e25df2500 to your computer and use it in GitHub Desktop.
Save danaugustin/b7f143f9584401007f17273e25df2500 to your computer and use it in GitHub Desktop.
AD UPN Update
Import-Module ActiveDirectory
$oldSuffix = "pnl.com"
$newSuffix = "petenetlive.com"
$ou = "OU=Test,DC=pnl,DC=com"
$server = "DC-01"
Get-ADUser -SearchBase $ou -filter * | ForEach-Object {
$newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix)
$_ | Set-ADUser -server $server -UserPrincipalName $newUpn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment