Pages

Wednesday, October 17, 2012

Deleting the default mailbox database after an install of Exchange Server 2010

For those who have deployed Exchange Server 2010 will know that by default the installation creates a mailbox database named Mailbox Database <some random #> that is almost certain to be removed due to the naming convention.  I’ve found that I’ve come across having to do this enough times over the past 4 months where I would look into my old notes of what I needed to do to warrant a blog post that I can reference to in the future.

Problem

You’ve just completed installing a new Exchange Server 2010 in either a new organization or existing organization with Exchange Server 2003 or 2007 and notice that the default mailbox database created cannot be renamed and does not conform to your naming convention:

image

You attempt to delete the mailbox database by right clicking on the item and selecting Remove:

image

… but you’re presented with the following error:

--------------------------------------------------------
Microsoft Exchange Error
--------------------------------------------------------
The mailbox database 'Mailbox Database 1481773944' cannot be deleted.

Mailbox Database 1481773944
Failed
Error:
This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, or arbitration mailboxes. To get a list of all mailboxes in this database, run the command Get-Mailbox -Database <Database ID>. To get a list of all mailbox plans in this database, run the command Get-MailboxPlan. To get a list of archive mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -Archive. To get a list of all arbitration mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -Arbitration. To disable a non-arbitration mailbox so that you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID>. To disable an archive mailbox so you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID> -Archive. Arbitration mailboxes should be moved to another server; to do this, run the command New-MoveRequest <parameters>. If this is the last server in the organization, run the command Disable-Mailbox <Mailbox ID> -Arbitration -DisableLastArbitrationMailboxAllowed to disable the arbitration mailbox. Mailbox plans should be moved to another server; to do this, run the command Set-MailboxPlan <MailboxPlan ID> -Database <Database ID>.

image

Solution

The reason why this error is thrown is because the mailbox database that’s being deleted contains one or more of the following type of mailboxes:

  1. Mailbox
  2. Mailbox plans
  3. Archive mailboxes
  4. Arbitration mailboxes

The worse thing you can do at this point is to try to use adsiedit to delete the database because semi hidden mailboxes you do not see in the Exchange Management Console will have broken lines.  What you should do is preform the following steps:

Move Regular Mailboxes

Begin by opening up the Exchange Management Console, navigate to Microsoft Exchange On Premises –> Recipient Configuration –> Mailbox and use the GUI to move the mailboxes to a new mailbox database:

image

Move Arbitration Mailboxes

Once the regular mailboxes have been moved, proceed with moving the arbitration mailboxes.  You can view these mailboxes via the cmdlet:

Get-Mailbox -database “<the mailbox database to be removed>” -arbitration

image

Notice how the screenshot above has 3 mailboxes listed.  Proceed with piping in the additional cmdlet to move th mailboxes:

Get-Mailbox -database “<the mailbox database to be removed>” -arbitration | New-MoveRequest -TargetDatabase <your new database>

image

The output above shows that the new local move request has been initiated and queued.  You can check on the status of the move through the Exchange Management Console via Microsoft Exchange On-Premises –> Recipient Configuration –> Move Request:

image

Once the mailboxes have been moved, initiating the cmdlet:

Get-Mailbox -database “<the mailbox database to be removed>” -arbitration

… should no longer display any output:

image

With these mailboxes moved, you should now be able to delete the mailbox database:

image

image

Note that while the mailbox database is removed in the Exchange Management Console, you’ll still need to manually delete the files which is usually located in:

C:\Program Files\Microsoft\Exchange Server\V14\Mailbox

image

1 comment:

Terence Luk said...

I also forgot to note that if the environment has multiple domains in the same forest using the Exchange server then it is important to execute the cmdlet:

Set-AdServerSettings -ViewEntireForest $True

So that all mailboxes from other domains are listed.