So an admin just accidentally removed one of your executives' Office 365 mailboxes or maybe an automation script has gone awry that decided to "clean up" your Office 365 tenant unintentionally. In that case, you've got some mailbox restoration to do! Why pay big money for expensive software when you can do it for free using some knowledge and a little PowerShell?

In this article, you will learn the different ways to restore or recover a deleted mailbox in Office 365 with real, step-by-step examples.

Requirements

This article will follow a How-To approach. If you plan to follow along with the examples, these are the requirements that must be in place.

"Deleted" Does Not Mean "Gone Forever"

When an Office 365 mailbox is deleted, it is not immediately removed. The deleted mailbox is only hidden and moved to the Soft Deleted Objects container in Office 365. At this point, the mailbox is considered as a Soft-Deleted mailbox.

A soft-deleted mailbox is available for recovery within 30 days. After 30 days, the soft-deleted mailbox will be Hard-Deleted or purged. Once the mailbox has been purged, recovery is no longer possible.

However, if a mailbox was put in litigation hold before it was deleted, the mailbox will become an inactive mailbox and will not be purged, indefinitely.

When you attempt to restore or recover a mailbox in Office 365, note that only Soft-Deleted (including inactive) mailboxes can be restored or recovered. Hard-Deleted mailboxes are permanently deleted and are not recoverable.

These statements aren't meant to confuse you but to let you know you can get mailboxes back under just about any circumstance!

Using Office 365 Admin Center to Restore a Deleted Mailbox

Before going any further, please make sure that your Office 365 account is assigned with a global admin or user management admin privileges in Office 365. Otherwise, the following steps will not work for you.

Note: The Office 365 Admin Center is now known as the Microsoft 365 Admin Center. But, for the sake of familiarity, we will still refer to it as the Office 365 Admin Center.

Restoring deleted mailboxes can be done from the Office 365 Admin Center. To do so, follow these steps.

First, using your browser, navigate to the Office 365 Admin Center, and log in using your admin account. Then, on the navigation menu on the left of the page, go to Users —> Deleted Users.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e1aecd40-afa5-499e-a0ac-db7dedb320bd/Untitled.png
Opening the Deleted Users page

Then, on the Deleted user page, you should see a list of the deleted users that are still available to be recovered. From the list, you can select one or more deleted users and click on the Restore user button.

In the example below, the deleted user with username [email protected] Is selected to be restored.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/db626084-d90a-4aeb-a0b3-88b3dde90b01/Untitled.png
Selecting one deleted user to be restored

The Restore flyout will show up to present you with options before restoring the mailbox. As you can see from the below, the restoration advises you to make sure that there's an available product license that will be assigned for the restored user.confirmation page, as

Restoring the mailbox will perform the following actions:

  • Restore all associated data.
  • Assign product licenses.
  • Give access to all services that the user can access before.

Select the options that you deem appropriate or that are compliant with your organization's policies. After making your selections, click the Restore button.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/bea071e5-b2fa-41bd-9c13-32bc25689434/Untitled.png
Select options before restoring the mailbox

Once the restore operation is complete, you will get a confirmation page as shown below. You can choose to send the new password by email, then click on Send email and close.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/db486f0f-cbbe-4e78-b687-8c9b20a65d85/Untitled.png
Confirmed user restoration

Once done, an email with the user login details that you can then share with the user, similar to the image below.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b85b7643-e1a8-4d97-9b57-4f3bee7e87f2/Untitled.png
User account details in an email message

Optionally, you can confirm that the mailbox is restored by checking in the Exchange Admin Center.

As you can see from the screenshot below, the mailbox [email protected] is listed under the available mailboxes list.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/0bda656f-0efd-4b06-95ad-25ffb46dfc51/Untitled.png
Mailbox is restored

Using Azure ActiveDirectory (MSOnline) PowerShell to Restore a Deleted Mailbox

You must have already installed the MSOnline module as a requirement before you can run any of the commands in this section.

First, you must connect to Azure AD using PowerShell. Then, to know details of the user that will be restored, run the command:

Get-MsolUser -ReturnDeletedUsers | Select-Object ObjectID,UserPrincipalName,isLicensed

When you run the code above, you should get the list of the deleted users that are available for restoration. Take note of the ObjectID value of the user that you need to restore. See the screenshot below as an example.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/86aeb581-70c1-4a18-bdfd-c0124f992c98/Untitled.png

Then, once you've selected the deleted user, you can restore it by using the command below. Make sure to change the <objectid> with the actual ObjectIDof the user object.

Restore-MsolUser -ObjectId <objectid> -AutoReconcileProxyConflicts

Once you run the command above in PowerShell, you should see a similar output, as shown below. In this example, the deleted user to be restored is [email protected].

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/220d74ca-fe7c-4d3f-bd30-c18aed27cce7/Untitled.png
Command to restore a deleted user

Then, you can run this next command to confirm that the user was restored as an active user.

Get-MsolUser -ObjectId <objectid>

-OR-

Get-MsolUser -UserPrincipalName <UserPrincipalName>

As you can see from the screenshot below, the restored user is found.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ba744ab6-fec4-4121-af3b-e4db41922ff1/Untitled.png
Restored user is found

Lastly, to confirm that the mailbox has been restored as well, you can either go to the Exchange Admin Center or Connect to Exchange Online PowerShell. If you prefer to check the mailbox via PowerShell, run this command:

Get-Mailbox -Identity <UserPrincipalName>

The screenshot below shows that the mailbox of the restored user has been restored as well.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/965481ad-e185-4bc3-ae2e-cc02897523af/Untitled.png
The mailbox was restored

Using Exchange Online PowerShell to Recover a Deleted Mailbox

Using the Exchange Online PowerShell module, you can also recover a mailbox using just a few commands. In this example, it is assumed that the user account has been deleted, which caused the mailbox to become a soft-deleted mailbox.

First, get the mailbox identity of the soft-deleted mailbox you intend to restore using the command below.

Get-Mailbox -SoftDeletedMailbox | Select-Object UserPrincipalName

After running the above command, you should get a list showing the list of the soft-deleted mailboxes with the UserPrincipalName property values.

In this example, the mailbox to be restored is the one with the name [email protected].

Next, run this command below to recover the mailbox. Make sure to replace the <UserPrincipalName> with the actual value of the mailbox UserPrincipalName.

Undo-SoftDeletedMailbox <UserPrincipalName> `
 -WindowsLiveID <UserPrincipalName> `
 -Password `
 (ConvertTo-SecureString -String '[email protected]$$w0rd' -AsPlainText -Force)

Once you run the command above, a new user account will be created and the recovered mailbox is linked to the new account. See the example below.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/8a77ef3e-e458-48d6-ace3-29d14a8aecea/Untitled.png
The mailbox was recovered.
Note: After the mailbox is recovered, you need to assign a product license to the user. Otherwise, the mailbox will be disabled after the 30-day grace period has passed.

Using Exchange Online PowerShell to Restore a Deleted Mailbox

Restoring a soft-deleted mailbox means that you are essentially copying the contents of the soft-deleted mailbox to another mailbox.

Note that in this example, the source mailbox is called TestAcct, and the target mailbox is called reports.

To restore the contents of the soft-deleted mailbox, you first need to get two values.

  • The Exchange of the soft-deleted mailbox (source)
  Get-Mailbox -SoftDeletedMailbox <MailboxID> |
  Select-Object Name,ExchangeGUID
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/afb41692-b5c5-4d76-b112-f83346e91ab8/Untitled.png
Get the ExchangeGUID of the target mailbox
  • The ExchangeGUID of the new mailbox (target)
  Get-Mailbox <MailboxID> |
  Select-Object Name,ExchangeGUID
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e506e89d-5e52-4102-835e-a3a5c7281805/Untitled.png
Get the ExchangeGUID of the target mailbox

Once you have the required ExchangeGUID values, you can initiate the restore using the command below. Make sure to change the <SourceExchangeGUID> and <TagetExchangeGUID> with the actual ExchangeGUID values of the source and target mailboxes.

New-MailboxRestoreRequest `
 -SourceMailbox <SourceExchangeGUID> `
 -TargetMailbox <TargetExchangeGUID> `
 -AllowLegacyDNMismatch

After running the command, you should see a confirmation that the restore request has been Queued. See the screenshot for reference.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c68739b3-a2f7-4fa5-8d0c-3c26c5e5f4b0/Untitled.png
Create the mailbox restore request

While waiting for the completion, you can monitor the progress by running this command below.

Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics

The output of the command above is similar to the screenshot below.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3d542127-dba2-4d73-86ef-5769b436540d/Untitled.png
Monitoring the mailbox restore request progress

Using Exchange Online PowerShell to Recover an Inactive Mailbox

An inactive mailbox is a type of soft-deleted mailbox that was put in litigation hold before it entered the soft-deleted state. When an inactive mailbox is recovered, a new user account is created, and the inactive mailbox is linked to it.

Before you can recover an inactive mailbox, first, you need to get the ExchangeGUID of the inactive mailbox. Use the command below to get the inactive mailbox details. Note that the InactiveMailboxOnly parameter ensures that only inactive mailboxes are returned.

Get-Mailbox -InactiveMailboxOnly |
 Format-List Name,DistinguishedName,ExchangeGuid,PrimarySmtpAddress

After running the command above, you should see the list of inactive mailboxes. Then, find the ExchangeGUID of the inactive mailbox you wish to recover. See the screenshot below as a reference.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/d8b3cc3e-2ce3-4507-ac11-ccdf6c3e3b97/Untitled.png
Inactive mailbox properties

The syntax below shows the minimum required set of parameters to recover an inactive mailbox.

New-Mailbox `
 -InactiveMailbox <InactiveMailboxGUID>`
 -Name <Name> `
 -FirstName <FirstName> `
 -LastName <LastName> `
 -DisplayName <DisplayName> `
 -MicrosoftOnlineServicesID <UPN> `
 -Password (ConvertTo-SecureString -String '[email protected]$$w0rd' -AsPlainText -Force) `
 -ResetPasswordOnNextLogon $true

Using the syntax above, replace the <Name>, <FirstName>, <LastName>, <DisplayName>, <UPN> values. After you've replaced the appropriate values, run the command in PowerShell as shown below.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/05555e5c-78c9-418a-9b1e-1917d9970322/Untitled.png
The inactive mailbox was recovered and linked to a new user
Note: After an inactive mailbox is recovered, you need to assign a product license to the user. Otherwise, the mailbox will be disabled after the 30-day grace period has passed.

After completing the recovery, you can confirm that the new mailbox is available by checking in the Exchange admin center or PowerShell as was done in the previous examples. And, if your company policy permits, access the mailbox using Outlook or Outlook on the Web (OWA).

Conclusion

There are several ways to either recover or restore a deleted mailbox in Office 365. These recovery and restore capabilities are built-in to Office 365 and are free to use.

Each method of mailbox restore can be used in specific scenarios where they may apply. Some methods are available in the Office 365 portal, while most are available through the use of PowerShell modules and scripts.

It is up to you to determine which method you deem appropriate to use for the conditions you may encounter when restoring Office 365 mailboxes.

Further Reading