ajdratch
asked on
Powershell command to fix UPN
I need to change the UPN for all users so I can migrate to office 365. I accidentally ran a powershell command on the entire domain instead of the test OU. Now all users UPN is just the @ symbol. When I go to Properties / Accounts, user logon name is correct but instead of the .local or .com domain, I just have the @ Symbol.
I can not figure out how to replace @ with their internet domain.
I can not figure out how to replace @ with their internet domain.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Pretty Straightforward:
$oldSuffix = ""
$newSuffix = "yourdomain.com"
$server = "Yourdomaincontroller"
Get-ADUser -ResultSize Unlimited | ForEach-Object {
$newUpn = $_.UserPrincipalName.Repla ce($oldSuf fix,$newSu ffix)
$_ | Set-ADUser -server $server -UserPrincipalName $newUpn
}
ref link: https://blogs.technet.microsoft.com/canitpro/2015/07/07/step-by-step-changing-the-upn-suffix-for-an-entire-domain-via-powershell/
$oldSuffix = ""
$newSuffix = "yourdomain.com"
$server = "Yourdomaincontroller"
Get-ADUser -ResultSize Unlimited | ForEach-Object {
$newUpn = $_.UserPrincipalName.Repla
$_ | Set-ADUser -server $server -UserPrincipalName $newUpn
}
ref link: https://blogs.technet.microsoft.com/canitpro/2015/07/07/step-by-step-changing-the-upn-suffix-for-an-entire-domain-via-powershell/
ASKER