Script for UPN change as email address

All about active directory tips and tricks
Post Reply
admin
Site Admin
Posts: 12
Joined: 21 Feb 2016 14:15

Script for UPN change as email address

Post by admin » 30 Nov 2018 11:22

Hi,

You can change the email id as the UPN address after adding the UPN prefix in to trust.



$UserCount = 0
Import-Csv -Path "C:\Users\migration\Desktop\email.csv" | ForEach-Object {
$UPN = $_.UserPrincipalName
Write-Host “Working on user:” $UPN
Get-ADUser -Filter {UserPrincipalName -Eq $UPN} | Set-AdUser -userprincipalname $_.EmailAddress
$usercount = $usercount +1
}
Write-Host “Number of users on your CSV: $UserCount”
Write-Host “UPN’s Changed”



Post Reply