Tuesday, December 3, 2013

Update UserPrincipalName–PowerShell Script

Here is a PowerShell script which you can use to update UPN (UserPrincipalName) in Active Directory

Import-Moudle ActiveDirectory
Get-ADUser -Filter * -SearchBase "OU=OU1,DC=Sivarajan,DC=Com" | ForEach {
$UpdatedUPN = $_.GivenName + "." + $_.SurName + "@Sivarajan.com"
Set-ADUser $_.samAccountName -UserPrincipalName $UpdatedUPN
}

I am using the Firstname.Lastname@domain.com format.  You can update the following line based on your UPN format.

$UpdatedUPN = $_.GivenName + "." + $_.SurName + "@Sivarajan.com"

1 comments:

Can you substitute setspn in order to update an SPN in ADUC?

Post a Comment

Popular Posts

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More