Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

PowerShell UPN Suffix not working

$
0
0

Hi

I have a powershell script that ive nicked from somewhere else which is supposed to change the UPN suffix on all of our accounts in the domain, but it doesn't work. if I use the -whatif switch it correctly displays a list of all the accounts it will affect, but when I remove the whatif switch nothing actually takes place. why would this be? im running under an administrator account which can normally make these changes in ADUC and the accounts in ADUC have the alternative UPN suffix available, I can manually set them fine. before I run the following script I use import-module activedirectory

#Replace with the old suffix
$oldSuffix = "my-domain.local"

#Replace with the new suffix
$newSuffix = "my-domain.co.uk"

#Replace with the OU you want to change suffixes for
$ou = "DC=my-domain,DC=local"

#Replace with the name of your AD server
$server = "main-server"

Get-ADUser -SearchBase $ou -filter * | ForEach-Object {
$newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix)
$_ | Set-ADUser -server $server -UserPrincipalName $newUpn
}

thanks

Steve


Viewing all articles
Browse latest Browse all 31638

Trending Articles