How to remove an alias stuck in Office 365Posted on 31 July 2019 by Beaming Support
Are you trying to remove an alias from an Office 365 mailbox/shared mailbox?
This can be an issue if the mailbox was originally created with the email address that you now want to move over to a separate mailbox. The issue is that when the account is first created it ties the email address into the user principal name (UPN) of the account, therefore when you try to remove the “alias” it will only re-appear again as it won’t let you remove the default UPN. This guide demonstrates how to change the UPN to the desired email address using some Powershell commands.
Connect to Office 365 via Powershell using the following commands.
$UserCredential = Get-Credential
(This will then prompt for credentials, which will be the Office 365’s admin email address and password).
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic –AllowRedirection
Import-PSSession $Session –DisableNameChecking
Once connected, it is advisable to do a “Get-Mailbox” command to ensure that you are logged in correctly and are in the correct Office 365 session. This will essentially list all of the mailboxes associated to that Office 365 admin panel.
Then you can check the specific mailbox using the following command.
You will need to connect to the MsolService to firstly check the mailbox’s User Principal Name and then change it. To connect the command is:
Now you are connected, you will firstly need to look at the mailbox you want to remove the alias from in more detail by using the following.
Get-Mailbox “firstname.lastname@example.org” | Format-List
In the list, you will need to locate the “UserPrincipalName”, which currently matches the alias you want to remove. The way to change this is to do the following.
Set-MsolUserPrincipalName -UserPrincipalName “Current@userprincipalname.com” -NewUserPrincipalName email@example.com.
Now run the Get-Mailbox “firstname.lastname@example.org” | Format-List command again and you should see the updated user principal name. You can now remove the alias from the Office 365 admin portal and reassign it where needed. Note that this may take a while to take effect, so if it does not work immediately wait up to 1 full hour for the change to be fully completed before trying again.
Subscribe & get a free Business Guide to Cyber Security
We’ll pop up in your inbox once a month with:
-Cyber security guidance for users of all ability levels
-FAQs from our technical support desk
-Quick tips that boost efficiency & productivity
And we’ll send you our Business Guide to Cyber Security for free, as soon as you sign up.