home Exchange Online, Office 365, Powershell Exchange Online – Remove mailbox without deleting user account

Exchange Online – Remove mailbox without deleting user account

This guide shows how to delete an Exchange Online mailbox, without deleting associated user account in Azure AD.

This can be verry usefull if you are about to setup a Hybrid environment whit your on-premises Mailserver.

If you delete the Azure AD user account then, obviously, mailbox is removed, but maybe we don’t want to do that, since users will lose all onedrive, teams data etc.

 

If you navigate to; https://admin.exchange.microsoft.com/#/mailboxes you will see the mailboxes i 365

Here we see Anders have a mailbox in 365

Remove the users Exchange Online License

Go to https://admin.microsoft.com/#/users and find the user (let’s take Anders Again) note Anders is currently not synced whit the local AD 

Click on Licenses and Apps and click on Apps

Remove the Exchange Online license and click Save

if we look back at https://admin.exchange.microsoft.com/#/mailboxes, we see the mailbox is now soft deleted (but not hard deleted, so if we give the user the Exchange Online license back, the mailbox will just come back again)

Connect to exchange online powershell

Now we have to purge the soft deleted mailbox

Run this command;

Set-User user@domain.com -PermanentlyClearPreviousMailboxInfo

And confirm to delete the mailbox

Y

Move the user back to an synced OU (optional)

Move the user to an OU in your local active directory that is your AD Connect sync scope, and make a fresh sync or wait 30mins (Start-ADSyncSyncCycle -PolicyType delta)

Now Anders is AD Synced

Give user the Exchange Online License back

Give Anders back his Exchange Online license, and click save

Lets take a look at Anders mailbox again. Now it shows This user’s local mailbox has not been migrated to Exchange Online. The Exchange Online mailbox is available when the migration is complete 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *