ishamsi
asked on
Script/method to change UPN suffix for all users in Active Directory
Hi,
I hope someone can help. I have seen similar questions about this issue but am yet to find something that works for me. Although I know my way round AD pretty well, I am fairly novice when it comes to scripting. The new UPN suffix I want to apply is already in AD and I can easily manually change it for individual users but need a method to change it for all users. I want to (naturally) run this against a test OU first to ensure it works as expected. The distinguished name of the OU is "OU=users,OU=test,DC=Emea, DC=domain, DC=net".
As I say, as I am a novice when it comes to scripting, a complete description of how to do this would be ideal.
Thanks
I hope someone can help. I have seen similar questions about this issue but am yet to find something that works for me. Although I know my way round AD pretty well, I am fairly novice when it comes to scripting. The new UPN suffix I want to apply is already in AD and I can easily manually change it for individual users but need a method to change it for all users. I want to (naturally) run this against a test OU first to ensure it works as expected. The distinguished name of the OU is "OU=users,OU=test,DC=Emea,
As I say, as I am a novice when it comes to scripting, a complete description of how to do this would be ideal.
Thanks
ASKER
Hi Will. I already found that through google but can't get it working. Have you tested it? So I just save the script as <name>.ps1 and run it in powershell?
You need to do a few things...
- Copy this into a txt file, change the file extension to .ps1
- Change the vaules for
#Replace with the old suffix
$oldSuffix = 'old.suffix' (your old domain suffix)
#Replace with the new suffix
$newSuffix = 'new.suffix' (your new domain suffix)
- I have replaced $OU = with your Testing OU location (no need to change)
- For $server = "add your DC server name"
Once you have changed those values you should then be able to run it on the Test OU and it should work fine. If you have any other questions let me know.
- Copy this into a txt file, change the file extension to .ps1
- Change the vaules for
#Replace with the old suffix
$oldSuffix = 'old.suffix' (your old domain suffix)
#Replace with the new suffix
$newSuffix = 'new.suffix' (your new domain suffix)
- I have replaced $OU = with your Testing OU location (no need to change)
- For $server = "add your DC server name"
Once you have changed those values you should then be able to run it on the Test OU and it should work fine. If you have any other questions let me know.
ASKER
Yeah, I know about adding my own suffixes etc so that's what I did. Let me run it again now and I'll let you know the error I get.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow! Thanks for that Mike. Embarassingly, I can't believe I never noticed that. Perfect solution. Thanks a lot.
ASKER
I should have noticed this! Top tip.
People don't use that much anymore, it was a big deal when it was introduced in Windows 2003.
Glad to help
Thanks
Mike
Glad to help
Thanks
Mike
#Replace with the old suffix
$oldSuffix = 'old.suffix'
#Replace with the new suffix
$newSuffix = 'new.suffix'
#Replace with the OU you want to change suffixes for
$ou = "OU=users,OU=test,DC=Emea,
#Replace with the name of your AD server
$server = "test"
Get-ADUser -SearchBase $ou -filter * | ForEach-Object {
$newUpn = $_.UserPrincipalName.Repla
$_ | Set-ADUser -server $server -UserPrincipalName $newUpn
}
Reference: http://community.spiceworks.com/scripts/show/1457-mass-change-upn-suffix
Thanks
Will