The Exchange server for the database object wasn’t found in Active Directory Domain Services

I have been working with my customer to upgrade from Exchange Server 2010 to Exchange Server 2016. During the design discussions, customer told us they tried to upgrade the exchange at their own but ran into some issues. After finalizing the design, we started to work on Exchange Server 2016 implementation. During the installation of Exchange Server 2016, we ran into a problem on step 10 related to “Exchange server for the database object wasn’t found in Active Directory Domain Services. The object may be corrupted

The Exchange server for the database object wasn't found in Active Directory Domain Services

Error:
The following error was generated when “$error.Clear();
Get-MailboxDatabase -Server $RoleFqdnOrName | Mount-Database -ErrorAction SilentlyContinue

” was run: “System.InvalidOperationException: The Exchange server for the database object “DB02″ wasn’t found in Active Directory Domain Services. The object may be corrupted.
at Microsoft.Exchange.Management.SystemConfigurationTasks.GetDatabaseTask`1.WriteResult[T](IEnumerable`1 dataObjects)
at Microsoft.Exchange.Management.SystemConfigurationTasks.GetDatabaseTask`1.InternalProcessRecord()
at Microsoft.Exchange.Configuration.Tasks.Task.<ProcessRecord>b__b()
at Microsoft.Exchange.Configuration.Tasks.Task.InvokeRetryableFunc(String funcName, Action func, Boolean terminatePipelineIfFailed)”.

The Exchange server for the database object “DB02” wasn’t found in Active Directory Domain Services. The object may be corrupted.
at Microsoft.Exchange.Management.SystemConfigurationTasks.GetDatabaseTask`1.WriteResult[T](IEnumerable`1 dataObjects)

How to fix it?

When i started to troubleshoot the issue, I verify that we do not have any database on Exchange Server 2010 that has a name of “DB02“. As per error, it definitely trying to connect the database DB02 which doesn’t exist. I decided to look at ADSIEdit to verify if we have any dormant object from previous upgrades that is causing this issue. Looking at the ADSIEdit, we can see that we do have a DB02 object but that database does not exist. I manually removed the DB02 from ADSIEdit and perform AD replication to replicate the changes. After removing the DB02 from ADSIEdit. I was able to install Exchange Server 2016 without any issues.

The Exchange server for the database object wasn't found in Active Directory Domain Services