If you are running O365 and syncing your Active Directory to Azure this may be a useful tool in your O365 Email Management Belt. This method is also needed if you are using MFA to authenticate to your O365 environment.
At times, the username (login name) of a user will pickup [email protected] instead of [email protected].
If this happens and you cannot change via ProxyAddress in the user Active Directory settings or from your O365 Management Portal, you can try this method.
Step 1: Making sure the username is correct in Active Directory #
Go the users properties in Active Directory, Attribute Tab, ProxyAddress option.
Make sure to add the email address for the user in the format of SMTP:[email protected].
The uppercase letters of the “SMTP” signify it will be the primary SMTP address of the user and the login name for O365.
The lower case “smtp” will signify an email alias or secondary SMTP address of the user.
Step 2: Open Powershell and change the username #
Open Powershell as an admin user. This step will connect you to your Azure (O365) environment using Powershell.
Changing a username or account name in O365 or Azure:
Checking to see if you have MSOnline installed in your Powershell Environment:
- Open Powershell as Admin
- Check and Install the latest MSOnline Module via Powershell
Get-Module -Name MSOnline
Find-Module -Name MSOnline
If you do not have the latest version or you do not have the module installed, do the following:
Install-Module -Name MSOnline
Once installed, connect to the O365
Connect-MsolService
Enter your credentials and authenticate to your O365 environment
Step 3: Change the username #
Change the username of O365 User Account after connecting to MsolService:
Set-MsolUserPrincipalName -UserPrincipalName "[email protected]" NewUserPrincipalName "[email protected]"
If you use MFA to connect and authenticate to manage your O365 environment or simply need to connect and change the username of a user in O365, this will work nicely.