Powershell: Change UPN on list of users

I needed a script to bulk change a list of users to a new UPN i came up with this.

$Users = gc c:\temp\users.txt | get-ADUser

foreach ($User in $Users)
$UserUPN = $User.UserPrincipalname
$UserUPNwithOutDomain = ([regex]::matches($UserUPN, "([^@]+)")).value[0]
Set-ADUser $User -userprincipalname "$UserUPNwithOutDomain@microsoft.com"


Popular posts from this blog

Powershell - Com+ Application Recycle

Powershell : Certutil Find Expired Certs on CA server