Microsoft Exchange 2013: Removing Deafult Mailbox Databases

Hello and Happy 2017!

Today I'd like to talk about removing the databases created during an Exchange 2013 setup.

During the setup of Exchange 2013, two mailbox databases are created on the server, usually named like "Mailbox Database ...". Since most Exchange setups are using a Database Availability Group, I usually remove those databases and create new ones with a more useful name.

Let's see those databases on a newly installed exchange server. Using the Get-MailboxDatabase cmdlet we get the databases on the server.

[PS] C:\Windows\system32>Get-MailboxDatabase

Name                           Server          Recovery        ReplicationType
----                           ------          --------        ---------------
Mailbox Database 1816881568    EXCHANGE2013A   False           None
IT                             EXCHANGE2013A   False           Remote
Systems                        EXCHANGE2013A   False           Remote
PublicFolders                  EXCHANGE2013A   False           Remote
Mailbox Database 1151137363    EXCHANGE2013B   False           None


[PS] C:\Windows\system32>

Here we can see three databases I've created myself (IT, Systems and PublicFolders) and the two databases created by setup (Mailbox Database 1816881568 and Mailbox Database 1151137363).

We will now use the Get-MailboxDatabase cmdlet again to see the file paths for the first database.

[PS] C:\Windows\system32>Get-MailboxDatabase "Mailbox Database 1816881568" | fl *path*


EdbFilePath             : C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database 1816881568\Mailbox Da
                          tabase 1816881568.edb
LogFolderPath           : C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database 1816881568
TemporaryDataFolderPath :



[PS] C:\Windows\system32>


Before removing the database, we will check if there are any mailboxes in it using the Get-Mailbox cmdlet.

[PS] C:\Windows\system32>Get-Mailbox -Database "Mailbox Database 1816881568"

Name                      Alias                ServerName       ProhibitSendQuota
----                      -----                ----------       -----------------
Administrator             Administrator        exchange2013a    Unlimited
Christos Polydorou        cpolydorou           exchange2013a    Unlimited
Test Shared Mailbox       TestSharedMailbox    exchange2013a    Unlimited
Test Room Mailbox         TestRoomMailbox      exchange2013a    Unlimited


[PS] C:\Windows\system32>New-MoveRequest -Identity Administrator -TargetDatabase IT

DisplayName               StatusDetail              TotalMailboxSize          TotalArchiveSize         PercentComplete
-----------               ------------              ----------------          ----------------         ---------------
Administrator             Queued                    688.6 KB (705,167 bytes)                           0


[PS] C:\Windows\system32>

As you can see, there are several mailboxes on that database and we have to move them to another database using the New-MoveRequest cmdlet. Arbitration, Archive and System mailboxes should also be moved in case this database is the first database created.

When all mailboxes are moved from the database, it's time to remove it.

[PS] C:\Windows\system32>Remove-MailboxDatabase "Mailbox Database 1816881568"

Confirm
Are you sure you want to perform this action?
Removing mailbox database "Mailbox Database 1816881568".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): y
WARNING: Failed to remove monitoring mailbox object of database "Mailbox Database 1816881568". Exception: Active
Directory operation failed on DC1.LAB.local. This error is not retriable. Additional information: Access is denied.
Active directory response: 00000005: SecErr: DSID-03152501, problem 4003 (INSUFF_ACCESS_RIGHTS), data 0
.
WARNING: The specified database has been removed. You must remove the database file located in C:\Program
Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database 1816881568\Mailbox Database 1816881568.edb from your
computer manually if it exists. Specified database: Mailbox Database 1816881568
[PS] C:\Windows\system32>Get-MoveRequest
[PS] C:\Windows\system32>

We got a warning message here that the monitoring object was not removed from Active Directory, let's remove it ourselves.

For every mailbox database copy there is a health mailbox object under the Microsoft Exchange System Objects\Monitoring Mailboxes OU in Active Directory. In order to identify the object that corresponds to the database we have to examine the display name attribute of the health mailboxes.

The display names of the health mailboxes are constructed using the name of the server and the name of the database. In our case the display name of the health mailbox is "HealthMailbox-Exchange2013a-Mailbox-Database-1816881568" (the name of the server is Exchange2013a).

Get-ADUser -SearchBase "CN=Monitoring Mailboxes,CN=Microsoft Exchange System Objects,DC=LAB,DC=local" -LDAPFilter "(DisplayName=HealthMailbox-Exchange2013a-Mailbox-Database-1816881568)" -Properties "DisplayName" |
    Remove-ADObject -Recursive

Now that we have removed the monitoring object from Active Directory, let's take a look on the second warning message about the database files.

The database files were not removed, possibly because the command was issued on a server other that the one hosting the database, but we have the paths from the second command above.

We have to navigate to the C:\Program Files\Microsoft\Exchange Server\V15\Mailbox folder on the Exchange2013A server and remove the Mailbox Database 1816881568 folder.

Were done, the database have been removed successfully.










Popular posts from this blog

Syslog Message Collection for OMS from sources that do not support the agent

Generating Alerts On OMS

How to Configure Message Forwarding on a Mailbox Level