Skip to content

Hard delete mailbox without deleting user account in Microsoft 365

How to hard delete a mailbox in Microsoft 365 without deleting the user account? Removing the user completely means that the mailbox, including the Teams, OneDrive, and SharePoint files, will be deleted. Instead, you want to keep the user and delete just the mailbox, leaving everything else. This article will show how to permanently clear previous mailbox info and keep the user identity in Microsoft 365.

Clear Exchange Online mailbox info

Migrating mailboxes to Microsoft 365 is great when everything is tested and planned. However, it can happen that you will find a mailbox on-premises and a mailbox in the cloud for the same user identity. When this occurs, it means that something went wrong with the Microsoft Entra Connect Sync between on-premises and the cloud. So, it’s essential to fix that because mail flow issues will happen if you don’t.

These issues happen when you add an Exchange Online license to an on-premises mailbox before it’s synced with Microsoft Entra Connect Sync to the cloud.

Another reason is that you have a Microsoft 365 cloud-only organization, and you want to delete all the information from the mailbox.

Note: Microsoft provides the PermanentlyClearPreviousMailboxInfo parameter to delete the mailbox in Exchange Online and keep the user account in the cloud. This works for a Hybrid and cloud-only environment.

How to hard delete mailbox in Microsoft 365

To delete the Exchange Online mailbox and keep the user account, follow the steps below:

1. Connect to Exchange Online PowerShell

Run Windows PowerShell as administrator and Connect to Exchange Online PowerShell.

Connect-ExchangeOnline

2. Remove Exchange Online license

When you remove a license from a mailbox, it means that you soft-deleted the mailbox. It stays in a soft-delete state for 30 days, after which it will be automatically deleted. If you add the Exchange Online plan to the mailbox, the mailbox will connect to the user, including all the mailbox information.

To remove an Exchange Online license from a user in Microsoft 365, follow these steps:

  1. Sign in to Microsoft 365 admin center
  2. Expand Users > Active Users
  3. Click on the User
  4. Click on Licenses and apps
  5. Expand Apps
Hard delete mailbox without deleting user account in Microsoft 365 licenses
  1. Uncheck the Exchange Online license
  2. Click Save changes
Hard delete mailbox without deleting user account in Microsoft 365 remove EXO license
  1. You can get an error message that you need to remove other apps

In our example, we must remove Microsoft Defender for Office 365 (Plan 2) and Microsoft MyAnalytics (Full).

Hard delete mailbox without deleting user account in Microsoft 365 error
  1. Uncheck the apps
  2. Click Save changes

3. Get user mailbox status

Run the Get-User cmdlet to check that no mailbox is connected to the user.

Get-User "Richard.Grant@exoip.com" | Select-Object Name,*Recipient*

The output shows that the user has a mailbox, that’s because you should give it a few minutes time for the changes to be applied.

Name                                 PreviousRecipientTypeDetails RecipientType RecipientTypeDetails
----                                 ---------------------------- ------------- --------------------
03e95a20-3652-4895-af25-6deed0856081 None                         UserMailbox   UserMailbox

Keep running the command until you see the below output.

Name                                 PreviousRecipientTypeDetails RecipientType RecipientTypeDetails
----                                 ---------------------------- ------------- --------------------
03e95a20-3652-4895-af25-6deed0856081 UserMailbox                  MailUser      MailUser

Another command that you can run is the Get-Mailbox.

Get-Mailbox "Richard.Grant@exoip.com"

The output shows that the user mailbox couldn’t be found, which is correct because the Exchange Online license was removed.

Get-Mailbox: Ex6F9304|Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException|The operation couldn't be performed because object
'richard.grant@exoip.com' couldn't be found on 'AM0P195A003DC04.EURP195A003.PROD.OUTLOOK.COM'.

Now that we have verified that the user does not have a mailbox attached, we can proceed to the next step.

4. Clear previous mailbox info

Run the Set-User cmdlet, including the -PermanentlyClearPreviousMailboxInfo parameter, to hard delete the mailbox without deleting the user account in Microsoft 365.

Important: The Exchange Online mailbox will be PERMANENTLY deleted with the below command, and its unrecoverable.

Set-User "Richard.Grant@exoip.com" -PermanentlyClearPreviousMailboxInfo

The below message appears in the output. Press Y and Enter to confirm the action.

Confirm
Are you sure you want to perform this action?
Delete all existing information about user Identity:'Richard.Grant@exoip.com'?. This operation will clear existing values from Previous home MDB and Previous Mailbox GUID of the    
user. After deletion, reconnecting to the previous mailbox that existed in the cloud will not be possible and any content it had will be unrecoverable PERMANENTLY. This operation   
will also create an async task to purge all the mail data. You can check the status by running 'Get-User <Identity> | fl *Workload*' and check if DesiredMailboxWorkloads is set to  
null. Do you want to continue? Y

5. Get mailbox deletion status

The mailbox will not be deleted immediately. An excellent way to know when the mailbox is hard deleted is to run the below command.

Get-User "Richard.Grant@exoip.com" | fl *WorkLoad*

The DesiredMailboxWorkloads property shows the value Substrate.

MailboxWorkloads                   : Mail, Calendar, Contacts, Substrate
DefaultMailboxWorkloadsMask        : Mail, Calendar, Contacts, Substrate
DesiredMailboxWorkloads            : Substrate
DesiredMailboxWorkloadsModified    : 18/04/2024 11:20:20
DesiredMailboxWorkloadsGracePeriod : None

The value needs to be empty (Null). You can keep running that command until you see the empty value. In our example, the value changed to empty after 8 hours.

MailboxWorkloads                   : Mail, Calendar, Contacts, Substrate
DefaultMailboxWorkloadsMask        : Mail, Calendar, Contacts, Substrate
DesiredMailboxWorkloads            : 
DesiredMailboxWorkloadsModified    : 
DesiredMailboxWorkloadsGracePeriod : 

The mailbox is successfully deleted and the user identity is still available in Microsoft 365. In an Exchange Hybrid environment this is the message you will see when you click on Mail.

Hard delete mailbox without deleting user account in Microsoft 365 removed

You can now migrate a mailbox or assign the Exchange Online license to the user. Remember that the user will get a new mailbox.

Read more: Permanently delete users from Microsoft 365 »

Conclusion

You learned how to hard delete mailbox without deleting the user account in Microsoft 365. First, remove the Exchange Online license assigned to the user and verify that the mailbox is disconnected. After that, run the PermanentlyClearPreviousMailboxInfo parameter to remove (hard-delete) the mailbox from the cloud. But before you do that, ensure that you export the mailbox data, if there is any. Otherwise, the data will be deleted for good.

Did you enjoy this article? You may also like Mailbox type difference in Exchange Hybrid. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 4 Comments

  1. Echoing Pete’s earlier comment, I’ve found several of your articles to be extremely helpful Ali!

    If I do -PermanentlyClearPreviousMailboxInfo, can I re-add the mailbox after? We did a pilot migration from Google and were told the user wanted 6-8 other mailboxes as aliases, so migration essentially merged them all into his. Now it’s been decided they want the other accounts to go to Shared Mailboxes instead, which we plan to do by setting up the other accounts as Shared and then re-migrating the mailboxes, but I first need to clear this merged mailbox from 50 Gb down to nothing to start again (we’ve already migrated things to the user’s OneDrive and they have made many changes since then, so don’t want to remove the whole user and re-add). I’m thinking I can do the set-user with -PermanentlyClearPreviousMailboxInfo option to purge the mailbox, calendar, and contacts, but can I then re-enable the Mailbox functionality through either PS or Admin Center?

  2. Hello Ali

    I search and search and then I find your articles – and they always work. Excellent sir. You have the best info for Exchange Online.
    You are helping people all over the world with your articles. Keep it up.

    One thing I still find missing on Office365 for admins is : “Microsoft should have included a TEST MAIL button somewhere, where it could run several tests against the mailbox to make sure it is active, has a license, quota is ok etc. etc. This would be awesome.

  3. Hello.
    Thanks for sharing your info. If possible, please write in the post about deleting clients’ emails in exchange 2016 in a specific time period to create more free space. Thankful

Leave a Reply

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