Powershell mass update UPN in AD

on
Import-Module ActiveDirectory
$oldSuffix = "myolddomain.local"
$newSuffix = "mynewdomain.com"
$ou = "DC=yourdomain,DC=local"
$server = "Hostname"
Get-ADUser -SearchBase $ou -filter * | ForEach-Object {
$newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix)
$_ | Set-ADUser -server $server -UserPrincipalName $newUpn
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *