M365 Change Username After AD Connect Setup

Just a brief post today to outline how to change a Users Username on their Microsoft 365 account.

Why would you want to do this? There could be any number reasons, like the user has gotten married and their surname has changed, or simply that the Active Directory logon username doesn't match their primary email address.

So how do we achieve this?

We will use PowerShell to carry out this change, so open PowerShell as an administrator and carry out the following:

Logon to our M365 Tenant using our admin credentials after running the following command:

$LiveCred = Get-Credential

Once we've successfully logged on we'll create a new session:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection

Next we'll set the execution policy using the syntax below:

Set-ExecutionPolicy Unrestricted

Finally we can use the following syntax to change the username for our users profile. Just change original.name@matrix7.com.au and new.name@matrix7.com.au to suit your environment in the example below:

Set-MsolUserPrincipalName -UserPrincipalName "original.name@matrix7.com.au" -NewUserPrincipalName "new.name@matrix7.com.au"

This is especially handy when you're using AD Connect to replicate your on-premise Active Directory Users to M365 and their logon name does not match their email address. Your task is now complete...

If you've found this useful, you may want to sign up to our newsletter where you'll receive notices on when we post new articles and helpful "how tos". Just fill out your details below and we'll do the rest…

No Comments Yet.

Leave a comment

Sign up to our newsletter where you’ll receive notices on when we post new articles and helpful “how tos” to make your IT life easier.