How to Restore Inactive Mailboxes in Office 365: A Step-by-Step Guide

Microsoft 365 Exchange Online allows administrators to change a mailbox status to inactive if they need to disable an account without deleting the data. Accounts are usually disabled when users leave an organization temporarily or permanently. The inactive mailbox account cannot send or receive email messages. However, you may need to restore or recover data from inactive Microsoft 365 email accounts to gain access to important data stored in an old inactive email account. Fortunately, it is possible to recover and restore inactive email accounts and the data stored in them. This blog post explains the differences between recovering and restoring, and how to do both.

Backup for Microsoft 365 Data

Backup for Microsoft 365 Data

Use the NAKIVO solution to back up Microsoft 365 data in Exchange Online, Teams, OneDrive and SharePoint Online for uninterrupted workflows and zero downtime.

About Inactive Mailboxes

If you delete a mailbox in Office 365, the mailbox is soft-deleted. With soft deletion, there’s a retention period (30 days by default), after which the account is deleted permanently, or hard-deleted. Soft-deleted accounts can be recovered as inactive mailbox accounts. Depending on the Office 365 subscription plan and configuration, a recovered deleted account that is inactive can be preserved in the inactive state on Litigation Hold and by applying the retention policy after the default 30-day period. Sometimes administrators put email accounts on hold when a user temporarily leaves the company, for example, for medical reasons. This approach helps save costs on Office 365 subscriptions.

You can add a maximum of 1,000 mailboxes to the inactive mailboxes retention policy in Office 365. After the Exchange Online user account is deleted and is inactive in Office 365, the license is removed and is available for other Office 365 users. As a result, you don’t pay for inactive accounts that were deleted.

Restore or Recover?

There are differences between restoring an inactive mailbox and recovering an inactive mailbox. Let’s find out what these differences are.

When you recover an inactive mailbox:

  • A new mailbox account is created;
  • The old inactive mailbox is converted to a new mailbox; and
  • Content is transferred from the inactive mailbox to the new mailbox used to recover the email data.

The old inactive mailbox is then deleted and will not exist anymore after recovery is finished. Use inactive mailbox recovery when a user returns back to the organization or a new user is working at the same position as the user who has left the organization.

When you restore an inactive Office 365 mailbox, you can copy the content of the old inactive mailbox to a new active mailbox. It is also possible to restore an archived email from the inactive mailbox. After finishing the restore process, the inactive mailbox remains in the current inactive state and is not removed. Restored email data is accessible in the new account. Changes made to the restored data in the new (target) account don’t affect the source inactive mailbox.

NOTE: If an auto-expanding archive is configured for an inactive mailbox, you cannot recover or restore data from this inactive mailbox. In this case, you should use content search, export and then import data from the inactive mailbox.

Requirements

Before you proceed, ensure that the following conditions are met:

  • PowerShell 5.1 or later
  • Global admin privileges for a Microsoft 365 account for organizations or the user management administrator account
  • The Azure ActiveDirectory (MSOnline) module
  • The Exchange Online PowerShell V2 module

Unfortunately, the Exchange Online admin center cannot be used to restore Office 365 mailbox that is completely inactive.

Options to Restore Deleted Users in the Admin Center

If you have recently deleted the email account of an Office 365 user, you can try to restore the account in the Office 365 admin center. Open the web interface of the Office 365 admin center and go to Users > Deleted users. You need to use an administrator account to do this. Use this link to open the needed page in the Office 365 admin center:

https://admin.microsoft.com/Adminportal/Home/#/deletedusers

Select the deleted user and click Restore user.

Then select the needed options and assign a license for the account that is being recovered because the license was unassigned from the deleted user (the advantage is that you don’t need to pay for Office 365 user accounts that were deleted). Select the data to restore and select the Office 365 products that must be available for this user account. Set a new password for the restored account. The restored mailbox should now be displayed in your organization’s list of active mailboxes in the admin center.

How to Restore an Inactive Mailbox in PowerShell

Let’s see how to restore Office 365 mailboxes that are inactive in PowerShell. This route provides more capabilities compared to using the web interface of the Office 365 admin center.

First of all, you have to install the MSOnline module that includes PowerShell cmdlets to work in Azure Active Directory. You can install this module from the PowerShell Gallery with the command:

Install-Module MSOnline

You may need to set up the execution policy as remote signed:

Set-ExecutionPolicy RemoteSigned

Connect to Azure AD in PowerShell:

$Msolcred = Get-credential

Connect-MsolService -Credential $MsolCred

Enter your administrator credentials when prompted.

Check the detailed information about the user account that you want to restore:

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

The list of deleted user accounts is displayed. Save the ObjectID value for the user account (for example, a7dbba2a-53c1-3276-7bb4-3a68536d1b62).

Now use the Office 365 restore deleted email command to restore the deleted user account and the email data for this account:

Restore-MsolUser -ObjectId <objectid> -AutoReconcileProxyConflicts

Enter the objectID you saved before for the needed Office 365 user account (a7dbba2a-53c1-3276-7bb4-3a68536d1b62 in this case) instead of <objectid>.

Run one of these commands to verify whether the needed user was restored and is now an active user. Enter the appropriate ObjectID instead of <objectid> or mailbox name instead of <UserPrincipalName>:

Get-MsolUser -ObjectId <objectid>

Get-MsolUser -UserPrincipalName <UserPrincipalName>

If you can see the string with your user account in the PowerShell output, then this user account has been restored and is active now.

Open the Exchange admin center in a web browser and find the restored account in the list of active users. If you see the restored account, then the account has been restored successfully, and you follow the same steps to restore other Office 365 inactive mailboxes.

How to Restore Mailboxes in Exchange Online PowerShell

As an alternative, you can connect to Exchange Online in PowerShell and use Exchange Online PowerShell commands to perform Office 365 restore mailbox tasks. You need to install the Exchange Online PowerShell V2 module (EXO V2). This module can be installed from the PowerShell Gallery with the command:

Install-Module -Name ExchangeOnlineManagement -RequiredVersion 2.0.4

Read the blog post about Exchange Online PowerShell to learn more.

Run this command to see more information about inactive Office 365 mailboxes:

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

The list of Office 365 inactive mailboxes should be displayed after running the command.

Create the $InactiveMailbox variable that should contain the inactive mailbox properties.

$InactiveMailbox = Get-Mailbox -InactiveMailboxOnly -Identity <identity of inactive mailbox>

Use ExchangeGUID or DistinguishedName properties that are unique identifiers for mailboxes to define the identity of the needed Office 365 mailbox account. For example, the ExchangeGUID looks like 61325ebv-3542-5186-dca3-3abcbd3a1587.

To restore Office 365 mailboxes that are inactive and restore their content, including email messages, use this Office 365 restore mailbox command:

New-MailboxRestoreRequest -SourceMailbox $InactiveMailbox.DistinguishedName -TargetMailbox newuser365@nakivo.com -AllowLegacyDNMismatch

In this case, the data of the source inactive mailbox is merged into the appropriate email folders of the target mailbox that already exists.

As an alternative, you can use this command without using variables and defining the needed old and new email account identifiers:

New-MailboxRestoreRequest `

 -SourceMailbox <SourceExchangeGUID> `

 -TargetMailbox <TargetExchangeGUID> `

 -AllowLegacyDNMismatch

Enter the appropriate source and target Exchange GUID values. In the PowerShell output, you should see that the status of the task is Queued.

If you want to monitor the progress, use the command:

Get-MailboxRestoreRequest | Get-MailboxRestoreRequestStatistics

See the PercentComplete parameter in the output.

You can define a custom email folder in the target mailbox to which you want to restore Office 365 mailbox content of the selected inactive mailbox. For example, if you want to restore Office 365 mailbox data (email messages) to the Inactive Mailbox folder in the target Office 365 email account, you can use this command:

New-MailboxRestoreRequest -SourceMailbox $InactiveMailbox.DistinguishedName -TargetMailbox newuser365@nakivo.com -TargetRootFolder “Inactive Mailbox” -AllowLegacyDNMismatch

Restoring the Mailbox Archive

If you know that there is a mailbox archive in the inactive mailbox, try to restore the archive data. Create the $InactiveMailbox variable as explained before. TargetIsArchive and SourceIsArchive parameters are now specified in the command.

$InactiveMailbox = Get-Mailbox -InactiveMailboxOnly -Identity <identity of inactive mailbox>

In my case, I have the source archive in the inactive mailbox, and I need to restore the source archive to the active existing (target) mailbox. In this example, the Inactive Mailbox Archive folder is created in the target mailbox to store the restored archive data. The name of the target account is newuser365@nakivo.com.

New-MailboxRestoreRequest -SourceMailbox $InactiveMailbox.DistinguishedName -SourceIsArchive -TargetMailbox newuser365@nakivo.com -TargetIsArchive -TargetRootFolder “Inactive Mailbox Archive” -AllowLegacyDNMismatch

When the command is executed, wait until the restore process is finished, and then check the mailbox folders of the target Office 365 email account.

How to Recover Deleted Mailboxes in Exchange Online PowerShell

If you need to recover rather than restore an inactive mailbox, PowerShell commands can also help you. As for the restore Office 365 mailbox workflow, you should have the Exchange Online PowerShell V2 module installed in your PowerShell and need to get the information about the Office 365 inactive mailboxes identities:

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

Save the value for the ExchangeGUID or DistinguishedName properties for the needed inactive email account data from which you want to restore.

The next step is similar to the restore Office 365 mailbox walkthrough. Create the $InactiveMailbox variable that should contain the inactive mailbox properties.

$InactiveMailbox = Get-Mailbox -InactiveMailboxOnly -Identity <identity of inactive mailbox>

The command shown in the example below is used to recover data from the inactive mailbox to the new mailbox of John Smith (JohnSmith@nakivo.com). A new user account is created, and you have to assign the license for the new account.

New-Mailbox -InactiveMailbox $InactiveMailbox.DistinguishedName -Name JoghnSnith365 -FirstName John -LastName Smith -DisplayName “John Smith” -MicrosoftOnlineServicesID JohnSmith@nakivo.com -Password (ConvertTo-SecureString -String ‘New_Password1’ -AsPlainText -Force) -ResetPasswordOnNextLogon $true

You can also use the more convenient view of this command:

New-Mailbox `

 -InactiveMailbox <InactiveMailboxGUID>`

 -Name <Name> `

 -FirstName John `

 -LastName Smith `

 -DisplayName “John Smith” `

 -MicrosoftOnlineServicesID JohnSmith@nakivo.com `

 -Password (ConvertTo-SecureString -String ‘ New_Password1’ -AsPlainText -Force) `

 -ResetPasswordOnNextLogon $true

If you don’t assign a license within 30 days, the new account will be disabled. Check the recovered account in the Exchange Online admin center where you can also manage licenses.

Conclusion

This blog post looked at the native tools and methods to recover and restore Office 365 mailboxes that have been deleted and are inactive. Office 365 inactive mailboxes can be restored and recovered in PowerShell by connecting to Azure Active Directory and Exchange Online PowerShell. The appropriate PowerShell cmdlets and commands are used for this purpose.

As an alternative to native methods, you can restore Office 365 mailbox content from a backup. In this case, you should use a reliable Exchange Online backup solution that supports Office 365 email backup and allows you to recover or restore the entire mailbox and custom email messages from active and inactive Office 365 accounts to the source account or to another account.

NAKIVO Backup & Replication is the all-in-one data protection solution that supports Office 365 backup including data residing in Exchange Online, OneDrive for Business, and SharePoint Online.

1 Year of Free Data Protection: NAKIVO Backup & Replication

1 Year of Free Data Protection: NAKIVO Backup & Replication

Deploy in 2 minutes and protect virtual, cloud, physical and SaaS data. Backup, replication, instant recovery options.

People also read