Thursday, June 19, 2014

Exchange 2013 - removing mailbox databases

At some point, we may want to remove a mailbox database for various reasons. Exchange 2013 contains a default mailbox database with an automatically generated name. We can either rename this database or create other databases, based on our needs, and then remove the default database.

In Exchange 2013, there are various "system mailboxes" that may prevent removal of the database. In the following lines, I'll show the reader how to identify them and either move or remove them.

First, we'll identify the mailbox databases:

[PS] C:\>Get-MailboxDatabase | select name

Mailbox Database 0859128749

So we have the default mailbox database and EXDB-2 which I created after installation.

I want to remove "Mailbox Database 0859128749"

There are a couple options for the syntax. I'll use a variable for this:

[PS] C:\>$def = Get-MailboxDatabase "Mailbox Database 0859128749"

Now, if I attempt to remove the mailbox database, this is what happens:

[PS] C:\>Remove-MailboxDatabase $def

This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, public folder mailboxes or arbitration mailboxes [...].

(The message is quite long so I have not posted all of it.)

So now, I'll move or remove those various forms of mailboxes so we can later delete the mailbox database itself.


First, we'll list the "simple" mailboxes (as opposed to system mailboxes) present in the mailbox database:

[PS] C:\>Get-Mailbox -Database $def | select name

DiscoverySearchMailbox {D919BA05-46A6-415f-80AD-7E09334BB852}

Concerning the Discovery Search Mailbox, it is used for discovery searches related to compliance, for example. We have the option to move it or delete it. Since I've just installed Exchange (and have not performed any searches) I'll simply delete it:

[PS] C:\>Get-Mailbox "DiscoverySearchMailbox {D919BA05-46A6-415f-80AD-7E09334BB852}" | Remove-Mailbox

There is a prompt for confirmation stating that the command "will remove the Active Directory user object and mark the mailbox and the archive (if present) in the database for removal." That is OK.

I can move the other mailboxes with this cmdlet:

[PS] C:\>Get-Mailbox -Database $def | New-MoveRequest -TargetDatabase EXDB-2

I can observe the progress of the move with the Get-NewRequest cmdlet: Queued, InProgress, Completed:

[PS] C:\>Get-MoveRequest | fl Displayname,status

DisplayName : Vik Kirby
Status      : Completed

Mailbox Plans

The error message mentioned above states:

"To get a list of all mailbox plans in this database, run the command Get-MailboxPlan."

But apparently, there is no such cmdlet:

[PS] C:\>Get-MailboxPlan

Get-MailboxPlan : The term 'Get-MailboxPlan' is not recognized as the name of a cmdlet, function, script file, or operable program.

[PS] C:\>gcm Get-MailboxPlan

gcm : The term 'Get-MailboxPlan' is not recognized as the name of a cmdlet, function, script file, or operable program.

Note: "gcm" is an alias for the Get-Command cmdlet.

[PS] C:\>gcm *plan* | select name


Note: my research indicates that "mailbox plans" only exist in a hosted (or hybrid?) environment. Since that is not my case, I'll ignore that step and proceed to the next.

Archive mailboxes

Mailbox users may have archive mailboxes associated with their ordinary (or "regular") mailbox.

Here is how we could identify these mailboxes:

[PS] C:\>Get-Mailbox | where archivedatabase -eq $def

As we can see, there are no archive mailboxes present.

If there were such mailboxes, I could pipeline the results to the New-MoveRequest cmdlet to move them:

New-MoveRequest -ArchiveOnly -ArchiveDatabase "Target Mailbox Database"

Public Folder mailboxes

In Exchange 2013, public folders are now incoporated in the mailbox databases (there are no longer separate public folder databases).

[PS] C:\>Get-Mailbox -Database $def -PublicFolder
[PS] C:\>

I have none in the default mailbox database. Otherwise, they would be moved like other mailboxes.

Arbitration mailboxes

[PS] C:\>Get-Mailbox -Database $def -Arbitration | fl name

Name : SystemMailbox{1f05a927-715a-4a1b-80e0-a024dc8ff0f4}
Name : SystemMailbox{bb558c35-97f1-4cb9-8ff7-d53741dc928c}
Name : SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}
Name : Migration.8f3e7716-2011-43e4-96b1-aba62d229136
Name : FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042

Do I need to move these? Are there comparable mailboxes in the target mailbox database?

[PS] C:\>Get-Mailbox -Database EXDB-2 -Arbitration
[PS] C:\>

No... so I will move them:

[PS] C:\>Get-Mailbox -Database $def -Arbitration | New-MoveRequest -TargetDatabase EXDB-2

Removing the database

Now that all the mailboxes have been removed from the database, we can remove the database itself. We can use either the Exchange Admin Center (EAC) or the EMS. I'll use the latter option:

[PS] C:\>Get-MailboxDatabase "Mailbox Database 0859128749" | Remove-MailboxDatabase

Are you sure you want to perform this action?
Removing mailbox database "Mailbox Database 0859128749".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): A

We have to confirm the operation (above) and an error message displays:

WARNING: Failed to remove monitoring mailbox object of database "Mailbox Database 0859128749". Exception: Active Directory operation failed on DC2.mynet.lan. This error is not retriable. Additional information: Access is denied.
Active directory response: 00000005: SecErr: DSID-031520B2, problem 4003 (INSUFF_ACCESS_RIGHTS), data 0

However, this error does not prevent the deletion of the database:
WARNING: The specified database has been removed. You must remove the database file located in C:\Program Files\Microsoft\ExchangeServer\V15\Mailbox\Mailbox Database 0859128749\Mailbox Database 0859128749.edb from your computer manually if it exists. Specified database: Mailbox
Database 0859128749

We can manually delete this file (and the associated log files) as we would delete any other files.


  1. Hi,

    Increase response rates and return on investment by selecting our highly targeted and verified Australia B2B Email Lists of prospects from our business.

    Indutry Wise Email Database
    Technology Wise Email Database
    Country Wise Database for USA
    State Wise Email Database

  2. Excellent write up! In my limited experience, however, I’ve found out that to Convert edb to pst - EdbMails is the best option as it can handle most exchange recovery tasks gracefully. It supports export of mailboxes to PSTs and also has an extensive range of filtering options. It is a forensic recovery that can extract most data from even corrupt or inaccessible exchange databases.It supports public, private folder recovery along with migration to Live exchange and Office 365. Archive mailbox migration is also supported by edbmails