Tuesday, October 11, 2016

Deleting Faulty Default Mailbox Databases

Hi folks,

Just wanted to share with you about the adventure I've had recently. As you know when Exchange Server 2010 and later is installed on the mailbox servers default mailbox database is created named something like "Mailbox Database 123456". Normally, new highly available databases are created which are stored outside of the default installation drive. Normally they are deleted.

When I was trying to delete my database I would see error as below:


I would see the same when trying to dismount database (which is also an invisible step when a database is being deleted):



As this article suggests this database has misconfigured MsExchMasterServerOrAvailabilityGroup property. When a mailbox server is a member of DAG this value should be equal to DN of DAG, for a standalone mailbox server this value will be DN of server.

When running Get-MailboxDatabase  DB01 | Format-Table Name, MasterType against my problematic database, I would see value of the MasterType property (corresponds to the MsExchMasterServerOrAvailabilityGroup attribute mentioned above) as Server. It indicates that DAG doesn't own this DB. Normally when a server is added to DAG MasterType value should be DatabaseAvailabilityGroup. So in my case this value wasn't properly updated and I was getting the error I was getting when attempting to delete or dismount DB.

The only way to fix it is tweaking Exchange objects in the AD on low level. Make sure it is backed up because AdsiEdit is not nice enough to warn you when you mistakenly delete something or mess a setting up. Therefore you should really know what you do. Or have MS support being at call with you and direct you as you tweak AD objects.

To access DB properties we will need to ADSIEDIT.MSC and navigate to CN=Databases,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=CONTOSO,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=contoso,DC=com .

This is the AD container where Exchange stores information about mailbox databases. If mailbox database us called DB01 you will need to edit properties of CN=DB01 subcontainer.

We will need to open properties of mailbox database in AD and check the value of the attribute. In my case it was distinguished name (DN) of the mailbox server where it was hosted: CN=SERVER01,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=CONTOSO,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=contoso,DC=com

I had to tweak this value to the DN of DAG my server is part of:
CN=DAG01,CN=Database Availability Groups,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=CONTOSO,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=contoso,DC=com

After this I gave some time for the AD to replicate. After which I have executed the following command again:

Get-MailboxDatabase  DB01 | Format-Table Name, MasterType

This time output was like below:


After which you can run the following command to remove mailbox database:
Remove-MailboxDatabase DB01 -Confirm:$false

After hitting Enter the default database should be successfully removed. At least it was a case for me.



Enjoy!