How to Recover when a Mailbox Exists in both Exchange Online and On-Premises?

Summary: Sometimes, in a hybrid setup, a situation arises where a mailbox exists on both local Exchange Server and Exchange Online, leading to multiple issues. In this post, we will see how to recover when a mailbox exists on both local Exchange Server and Exchange Online. We will also mention an Exchange repair tool that can help if the mailbox or database gets corrupted.

When you have a hybrid setup, both the local Exchange Server and the Exchange Online act as one and a mailbox can reside either on the local Exchange Server or Exchange Online. You cannot have a particular user’s mailbox on both. There is mail flow to the local Exchange Server, if the mailbox is on-premises, and vice versa. There could be an issue during the move to Exchange Online due to which the mailbox on on-premises server remains active. If this happens, then there will be mismatch in data and risk of data loss.

As you can see in the above image, if a new email is sent to the “User 1”, it will be delivered to the local Exchange Server and will never reach the online mailbox.

How to Recover from this Situation?

You need to decide if you are going to keep the Exchange Online copy. This means that you have to disconnect the mailbox on the local machine and remove it from the setup. After this, the Exchange Online mailbox will become the primary mailbox.

Let’s start the process. Open the Exchange Management Shell (EMS) and save the SMTP Address, Legacy Exchange DN, and the Exchange Attributes by using the below scripts. But before that, set the PowerShell Format enumeration limit as unlimited.

$formatenumerationlimit = -1
Get-Mailbox "<mailbox>" | fl > C:\Temp\MailboxInfo.txt

This will provide all the information that you might need for the process.

When you have the information you need, disable the local counterpart on the on-premises Exchange Server using the following command.

Disable-Mailbox "<mailbox name>"

Note: If the local mailbox has litigation hold enabled, it must be disabled first. Else, you will not be able to disable the mailbox.

Now, you need to enable the online mailbox as the primary mailbox.

Enable-RemoteMailbox "<local user mailbox>" -RemoteRoutingAddress "<online address>"

The next step is to restore any custom proxy addresses that the user had from the local mailbox and other Exchange Server attributes which may have been purged when the mailbox was disabled. Now, add the LegacyExchangeDN value from the previous local mailbox as an X500 address using the below command.

Set-RemoteMailbox -Identity "user mailbox" -EmailAddresses @{add="x500:/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=<user identity>"}

After this is done, you need to get the GUID of both the database for the disconnected mailbox and the remote mailbox database by using the below commands.

Get-MailboxDatabase "<local database>" | fl *GUID*
Get-Mailbox "<user name>" | fl *ExchangeGUID*

Now, you need to copy the data from the local Exchange Server to the cloud mailbox. You need to restore the contents from the disconnected mailbox to the Exchange Online. For this process, you need to have the credentials of the admin account of your Exchange Server.

First, you need to run the below command to get the admin credentials.

$cred = Get-Credential

Then, run the mailbox restore request with the data you collected from the text file and the above command.

New-MailboxRestoreRequest -RemoteHostName "<exchange server>" -RemoteCredential $cred -SourceStoreMailbox "<exchange guid of disconnected mailbox>" -TargetMailbox "<exchange guid of cloud mailbox>" -RemoteDatabaseGuid "<guid of on-premises database>" -RemoteRestoreType DisconnectedMailbox

Note: The above process is not supported by the Exchange Server 2010.

Another important thing to note is that the command is designed to work on a single Exchange Server organization. The cross-premises restore jobs will fail due to mismatch between the local and online mailboxes. The mailbox request will end with the FailedOther status.

This is a normal behaviour. It should be disregarded as the migration and restore of the data is successful. To ensure that the data has been fully restored and all the items are moved to the online mailbox, you can use the following command.

Get-MailboxRestoreRequest "<mailbox's ID>" | `
Get-MailboxRestoreRequestStatistics -IncludeReport | `
select -ExpandProperty Report | `
select -ExpandProperty Entries | `
select -Last 2 | `
select -First 1

This will give you a full overview of the restore of data. You must check the report for any baditemsencountered, largeitemsencountered, and missingitemsencountered.

Conclusion

The above situation would not arise in a normal environment. However, if such a situation arises, you need to be prepared to mitigate the issue. You need to ensure that the data will be restored from the disabled mailbox. It is to be noted that you can run the scripts mentioned above if the mailbox is healthy, the database is healthy, and the hybrid setup is working well. If there is corruption in the mailbox or database, you will not be able to restore the data.

In this case, you need to take the help of a third-party Exchange Mailbox Recovery application. Stellar Repair for Exchange is a powerful application that can come in handy in such situations. The application can open multiple EDB files (healthy or corrupted), with no size limit and from any version of Exchange Server. You can granularly export the EDB data to PST and other file formats. You can also export the data to a live Exchange Server database or Office 365 tenant.

Related Post

Stellar Data Recovery

Trial Download is for Desktop or Laptop. Put your email id to receive the download link




Exit mobile version