Active Directory Script – update users UPN from txt file

$oldSuffix = “olddomain.com”

$newSuffix = “newdomain.com”

Get-Content “C:\files\users.txt” | Get-ADUser | ForEach-Object {

$newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix)

$_ | Set-ADUser -UserPrincipalName $newUpn

}

Share
Ryan Wilson
Azure and Office 365 Technical Architect | Microsoft Certified Solutions Associate: Office 365 | Microsoft Certified: Azure Solutions Architect Expert | Microsoft Certified Solutions Expert: Productivity | Microsoft 365 Certified: Enterprise Administrator Expert | Microsoft 365 Certified: Messaging Administrator Associate

Leave a Reply

Your email address will not be published. Required fields are marked *