Change UPN of all AD users in an OU
Leave a reply
Issue: You need to change the User Principal Name (UPN) on a large group of users
Solution: The following command will allow you to change the UPN of all users contained in a chosen OU.
Get-ADUser -Filter * -SearchBase 'ou=yourOU,dc=yourDomain,dc=com' -Properties userPrincipalName | foreach {Set-ADUser $_ -UserPrincipalName "$($_.samaccountname)@newupndomain.com"}
To test your command and determine who it would apply to, use only this portion initially:
Get-ADUser -Filter * -SearchBase 'ou=yourOU,dc=yourDomain,dc=com' Read more [...]