This article will show you how to change a User UPN for a single user and for multiple users using Windows PowerShell.
Before Change
In the below screenshot you can see my user before.
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2016/04/042016_0958_ChangeUserU1.png)
Set-User
To change the UPN, Open PowerShell from the Domain Controller (use run as administrator) and type the cmdlet below.
Set-User -UserPrincipalName test01@test.local -Identity test01
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2016/04/042016_0958_ChangeUserU2.png)
You can see the result below
![](https://ntweekly-3e2e1f4957bdf35452c0-endpoint.azureedge.net/blobntweekly18036ad1fb/wp-content/uploads/2016/04/042016_0958_ChangeUserU3.png)
Multiple Users
You can also do a bulk change using a text file with usernames.
Import-Module ActiveDirectory $oldSuffix = "test.local" $newSuffix = "test.com" Get-Content "C:\files\users.txt" | Get-ADUser | ForEach-Object { $newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix) $_ | Set-ADUser -UserPrincipalName $newUpn }
Or do a bulk change to all the users In Active Directory
Import-Module ActiveDirectory $oldSuffix = "test.local" $newSuffix = "test.com" $ou = "DC=test,DC=local" Get-ADUser -SearchBase $ou -filter * | ForEach-Object { $newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix) $_ | Set-ADUser -UserPrincipalName $newUpn }
Processing…
Success! You're on the list.
Whoops! There was an error and we couldn't process your subscription. Please reload the page and try again.
command should be set-aduser and not set-user