Change UPN through Powershell Scriptl


Import-Module ActiveDirectory

#Change old suffix according to your environment

$oldSuffix = ‘WIN2K8.COM’

#Change new suffix according to your environment

$newSuffix = ‘ABC.COM’

#Change OU according to environment, you want to change suffixes for

$ou = “OU=Test,DC=WIN2K8,DC=COM”

#Change the name of your AD server according to your environment

$server = “dc08.win2k8.com”

Get-ADUser -SearchBase $ou -filter * | ForEach-Object {$newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix)

$_ | Set-ADUser -server $server -UserPrincipalName $newUpn}

 

Note: Please make sure suffixes should be case sensitive according to your environment.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s