Created
January 8, 2018 19:25
-
-
Save sweeneyrobb/eae4e5aa20313a246c86cac11f6205fd to your computer and use it in GitHub Desktop.
A PowerShell script that will mass assign UPNs for users in previous domain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$oldSuffix = "old-domain.com" | |
$newSuffix = "new-domain.com" | |
Get-MsolUser | | |
Where-Object { $_.UserPrincipalName.EndsWith($oldSuffix) } | | |
ForEach-Object { | |
Set-MsolUserPrincipalName -ObjectId $_.ObjectID -NewUserPrincipalName ($_.UserPrincipalName.Replace($oldSuffix, $newSuffix)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment