Change UPN of all AD users in an OU

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’ -Properties userPrincipalName

Pre-requisites:

Launch the “Active Directory Module for Windows PowerShell” at a computer where AD Management Tools are installed.

Warning: Please test and run your commands carefully.

Related

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.