Files
Scripting/Powershell/PowerShell-Office365Admin/MSOnline/ChangeOnlineUserUPN.ps1
DistractADD cfddd4fad2 Added Files
2021-07-06 13:16:46 +10:00

17 lines
518 B
PowerShell

# Update Online User UPN - when AD sync doesn't do it.
# Import the MSOL module and connect
Import-Module MSOnline
Connect-MsolService
# Whose UPN are we changing?
$oldUPN = Read-Host -Prompt 'Enter user''s old UPN in the format username@domain'
# What are we changing it to?
$newUPN = Read-Host -Prompt 'Enter user''s new UPN in the format username@domain'
# Change the UPN
if (Get-ADUser -Identity $newUPN.Split('@')[0]) {
Set-MsolUserPrincipalName -UserPrincipalName $oldUPN -NewUserPrincipalName $newUPN
}