07
Jan 2021
Office 365 Changing usernames
I’ve seen a few times, where someone needs a new username in office365. Sometimes it happens from the Service Desk doing a typo in a user account creation and it syncs up to AzureAD from onpremise AD and sometimes its because of a relationship change.
Now, if you’re syncing from AzureAD you’ll see when you click Manage Username, a warning that this change must happen from Onpremise AD because it’s sync’d. Well, if you’ve checked the AD Attributes and SMTP is correct and you see nothing wrong in AD, its time for powershell.
First things first, lets make sure you have the right modules for the job. In this case, you need the MSOnline module.
Install-module MSOnline
Now, other modules I find useful when working with AzureAD and Office365 include (but not needed for this blog):
Install-module AzureAD Install-module MicrosoftTeams Install-module ExchangeOnlineManagement
Once the module is installed, lets get to work fixing an account. In this example, lets say the username is currently [email protected] and we need to make it [email protected]. Here’s how we do it.
Connect-MSolService Get-MsolUser -UserPrincipalName [email protected] Set-MsolUserPrincipalName -NewUserPrincipalName [email protected] -UserPrincipalName [email protected] Get-MsolUser -UserPrincipalName [email protected]
There ya go.. an updated username.