Restore Deleted Mailbox in O365/M365/EXO

Restore Deleted Mailbox in O365/M365/EXO

Introduction

In the event one of your users has been completely removed from Azure AD/Entra ID (including has been removed from the Entra Deleted Users/recycle bin), you are basically in the worst scenario possible, as a restore of the old account (and relationships in Teams, Exchange, One Drive, One Note etc.) is simply not possible anymore. Whatever backup, or retention solution you have in place, if the user was completely deleted from Azure (hard delete), you cannot revert it to a happy state, you will have to create a new user. In this case, your user will feel a lot of pain, as they would have lost access to the mails, calendar events, Teams conversation history, also other people will see this user twice in their Teams:

  • once due to their old conversation with the person
  • twice due to the newly provisioned account

Generally mailboxes are kept as SoftDeleted mailboxes for another 30 days by default. If you have a retention policy in place, even more (see post related to retention)

In this post, we will assume the scenario in which your user in question was deleted from Azure (and Azure Deleted Users), you then recreated a new Azure user, licensed it (created a new, empty mailbox), and you need to restore the contents of the soft deleted mailbox (former mailbox) into the new one.

Steps to restore mailbox

First you will need to identify if there is a SoftDeletedMailbox for your user. You can use PowerShell to do so:
Connect-ExchangeOnline
Get-Mailbox -SoftDeletedMailbox <user@domain.com>

Or you can check from the GUI:
https://compliance.microsoft.com/ -> Data lifecycle management -> Microsoft 365 -> Inactive Mailboxes
Inactive Mailboxes.png

If you found the old mailbox there, you're in luck! You can restore it into the new, empty mailbox.

You'll need to identify the ExchangeGuid for both the SoftDeleted one and the new one:
Get-Mailbox -SoftDeletedMailbox <oldmailbox@domain.com>| select guid
Get-Mailbox <newmailbox@domain.com> | select guid

Then you can start the restore process, which can take several hours depending on the size of the mailbox:
New-MailboxRestoreRequest -SourceMailbox <OldMailbox GUID> -TargetMailbox <NewMailbox GUID> -AllowLegacyDNMismatch

Conclusion

Make sure you avoid hard deleting users. But if it happened, then use the above steps to alleviate the experience for the user and at least restore their emails.