To change default UPN suffixes for a particular OU.

JanakKhadka 596 Reputation points
2022-12-23T09:45:08.997+00:00

I have multiple UPN suffixes in my Active Directory. I need to change default UPN suffix for an Organizational Unit from by default one to newly added UPN suffix.
Can you please help me on this ?

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. !Daniel Bradley 1,066 Reputation points
    2022-12-23T11:04:10.59+00:00

    Hey @Janak

    Try this:

    $Users = Get-ADUser -Filter {UserPrincipalName -like '*YOURCURRENTUPN.local'} -SearchBase ",OU=EXAMPLE,DC=YOURDOMAIN,DC=local" -Properties UserPrincipalName -ResultSetSize $null  
    $Users | foreach {$newUpn = $_.UserPrincipalName.Replace("YOURCURRENTUPN.local","NEWUPN.com"); $_ | Set-ADUser -UserPrincipalName $newUpn}  
    
    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.