Skip to content

Cannot delete mailbox database in Exchange Server

You cannot delete mailbox database in Exchange Server and an error is showing. Error: This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, public folder mailboxes or arbitration mailboxes. Why is that happening and what is the error telling?

In this article, you will learn why you cannot delete a mailbox database and the solution to the error.

Cannot delete mailbox database solution

The solution to the error is to make sure that there are no mailboxes in the database. If there are mailboxes in the database, you are not granted to delete the mailbox database in Exchange Server. You have to check all the mailboxes one by one in the mailbox database and move them to another database.

Cannot delete mailbox database Exchange 2016 error

Error: This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, public folder mailboxes or arbitration mailboxes, Audit 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 public folder mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -PublicFolder. To get a list of all arbitration mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -Arbitration. To get a list of all Audit mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -AuditLog. 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. To disable a public folder mailbox so that you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID> -PublicFolder. To disable a Audit mailbox so that you can delete the mailbox database, run the command Get-Mailbox -AuditLog | Disable-Mailbox. 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>.

Before starting to move mailboxes to another database

Before you move the mailboxes, run the Set-ADServerSettings cmdlet, including the -ViewEntireForest parameter. This will let you view the objects in the entire forest.

Set-ADServerSettings -ViewEntireForest $true

Check databases

Do you know to which database you will migrate the mailboxes? Run the Get-MailboxDatabase cmdlet, including the -Status parameter, to check which mailbox databases are present and whether they are mounted.

Read more: Check mailbox database mount status in Exchange Server »

Get-MailboxDatabase -Status | Sort Name | Format-Table Name, Server, Mounted

The mounted mailbox databases appear.

Name Server    Mounted
---- ------    -------
DB01 EX01-2016    True
DB02 EX01-2016    True

Move mailboxes to another database

In our example, we are going to delete the mailbox database DB01. Before we can do that, we need to move the mailboxes. We are going to move all the mailboxes to the mailbox database DB02. The monitoring mailboxes associated with the mailbox database DB01 will be disabled.

Mailbox

Run Get-Mailbox to find all mailboxes in the database that you are going to delete.

Get-Mailbox -Database "DB01" -ResultSize Unlimited

Move all mailboxes from one database to another with the New-MoveRequest cmdlet.

Get-Mailbox -Database "DB01" -ResultSize Unlimited | New-MoveRequest -TargetDatabase "DB02"

Mailbox Plan

Mailbox plan is not relevant for on-premises Exchange environments. It’s only available in cloud-based service.

A mailbox plan is a template that automatically configures mailbox properties in Exchange Online. Mailbox plans correspond to Office 365 license types. When you assign a license to a new user, the corresponding mailbox plan is used to configure the settings on the new mailbox that’s created. If you change the license that’s assigned to an existing user, the settings in the mailbox plan that’s associated with the new license are applied to the user’s existing mailbox.

Archive mailbox

Find archive mailboxes in the database.

Get-Mailbox -ResultSize Unlimited | Where {$_.ArchiveDatabase -like "DB01"}

Move archive mailboxes to another database.

Get-Mailbox -ResultSize Unlimited | Where {$_.ArchiveDatabase -like "DB01"} | New-MoveRequest -ArchiveTargetDatabase "DB02"

Public folder mailbox

Find public folder mailboxes in the database.

Get-Mailbox -Database "DB01" -PublicFolder

Move public folder mailboxes to another database.

Get-Mailbox -Database "DB01" -PublicFolder | New-MoveRequest -TargetDatabase "DB02"

Arbitration mailbox

Find arbitration mailboxes in the database.

Get-Mailbox -Database "DB01" -Arbitration

Move arbitration mailbox to another database.

Get-Mailbox -Database "DB01" -Arbitration | New-MoveRequest -TargetDatabase "DB02"

Audit Log mailbox

Find audit log mailboxes in the database.

Get-Mailbox -Database "DB01" -AuditLog

Move audit log mailboxes to another database.

Get-Mailbox -Database "DB01" -AuditLog | New-MoveRequest -TargetDatabase "DB02"

Monitoring mailbox

Microsoft has not written in the error log to find and move monitoring mailboxes in the database. The best practice is to not move the monitoring mailboxes between mailbox databases. In my experience, it’s best to find the monitoring mailbox and disable them. If you don’t, you get a warning after deleting the mailbox database. Also, the health mailboxes will be in a corrupt state. Read the article check Exchange health mailboxes.

Find monitoring mailboxes associated with the mailbox database.

Get-Mailbox -Database "DB01" -Monitoring | Format-Table Name, DisplayName, Database, Servername

Disable monitoring mailboxes.

Get-Mailbox -Database "DB01" -Monitoring | Disable-Mailbox -Confirm:$false

Verify mailboxes move

Verify that all the mailboxes are moved. After that, remove completed move requests. If you don’t, you will get the error this mailbox database is associated with one or more move requests. If you want to remove all move requests, run the third command.

Get-MoveRequestStatistics -MoveRequestQueue "DB02"

Get-MoveRequest -MoveStatus Completed -ResultSize Unlimited | Remove-MoveRequest -Confirm:$false

Get-MoveRequest -ResultSize Unlimited | Remove-MoveRequest -Confirm:$false

Remove the mailbox database

Sign in to Exchange Admin Center. Click servers in the feature pane and click the databases tab. Select the database that you want to dismount in the list view. Click the More … icon in the toolbar and click Dismount.

Cannot delete mailbox database Exchange 2016 dismount database

After dismounting the database, select the database in the list view and click the delete icon in the toolbar.

Cannot delete mailbox database Exchange 2016 delete mailbox database

A warning will show if you are sure to delete the database. Click Yes.

Another warning message shows that the specified database has been removed. Note that we have to remove the database file from the system manually.

Start File Explorer on the Exchange Server and go to the location of the database. Delete the database and the logs folder.

Find remaining mailboxes

If you’re still unable to delete the mailbox database, it means the database still lingers in the organization.

Create a Temp folder in the (C:) drive. After that, run the below command.

dsquery * forestroot -attr * -limit 0 > "c:\temp\result_dsquery.txt"

You can also run the below command.

Get-ADUser -Filter * -Properties * | Out-File -FilePath "c:\temp\result_PS.txt"

Open the result_dsquery.txt or result_PS.txt file with Notepad or Notepad++ and search for the database name. Once you identify which user accounts still have the mailbox database added, go into ADSI Edit and clear the value from them.

Return to the previous step and remove the mailbox database from the Exchange Server.

Remove mailbox database with ADSI Edit

You did all the above steps and still can’t remove the Exchange Server mailbox database. It means that the mailbox database is still in the AD configuration present.

Note: It’s not recommended to use ADSI Edit for Exchange tasks. There are situations where ADSI Edit is your last option.

To remove the Exchange Server mailbox database with ADSI Edit, follow the below steps:

  1. Start ADSI Edit on the Exchange Server or Domain Controller
  2. Click Connect to…
  3. Select Configuration
  4. Click OK
Cannot delete mailbox database Exchange Server ADSI Edit connect
  1. Expand CN=Configuration, DC=exoip, DC=local > CN=Services > CN=Microsoft Exchange > CN=EXOIP > CN=Administrative Groups > CN=Exchange Administrative Group > Databases.

Note: Select your internal domain instead of EXOIP.

  1. Right-click the mailbox database and click Delete
Cannot delete mailbox database Exchange Server ADSI Edit delete database
  1. Click twice on Yes to delete the container and everything in it
  2. Sign in to Exchange Admin Center and verify that the mailbox database has been deleted

Keep reading: Pause mailbox move request in Exchange Server »

Conclusion

You learned why you are getting an error and cannot delete a mailbox database in Exchange Server. Use the above commands to move all mailboxes to another database. After that, delete the mailbox database in Exchange Server. As of last, delete the mailbox database and log files manually in File Explorer.

Did you enjoy this article? You may also like Enable circular logging in Exchange Server. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 11 Comments

  1. to find what folder or files DB01 use are, run below:
    # note some of the folders may be also be used by other databases.
    Get-MailboxDatabase DB01 | Select-Object Name, *Path

  2. I’m encountering the same problem. In my case though I have mailboxes that are located on multiple databases:

    example

    jsmith is on DB01 but also on DB10
    I’ve moved the account from DB01 to DB10 using the eac but it still remains on DB01 and is now also on DB10. EAC reports that the account is on DB10. Is there anyway to remove these artifacts? I’m seeing this with HealthMailBox’s, In Place Archives and SystemMailbox’s. The system says they are located elsewhere but still exist in DB01.

    Jason

    1. I encountered this problem as well, however it turned out that the duplicate mailboxes were not what was preventing the DB from being removed.
      There was an account in the domain that had the database listed in the homeDB attribute, and clearing that allowed me to remove the database despite those duplicate mailboxes.

      I recommend following the “Find remaining mailboxes” section.

  3. How do you simply and authoritatively destroy *all* Exchange mailboxes? I’m not at all interested in moving them somewhere as this is the last and only Exchange server in the network and I’m TRYING to get rid of it (data has all been copied to PST files). So how doers one utterly destroy all traces of Exchange from their network when literally *all* of the (online) help on this subject assumes that nobody could or would ever need or want such a thing?

    Why exactly isn’t there a “Remove MS Exchange, Root and Stem, From your ENTIRE Network” option in the uninstall process? ????????

  4. Great Guide – one thing missing though. You also need to clear down any mailbox export reports if any exist.

    Get-MailboxExportRequest | Remove-MailboxExportRequest

    1. I tried to reproduce the issue, but I can’t confirm.

      What I did:
      – Export a mailbox that’s located on DB01 to PST file
      – Run the cmdlet Get-MailboxExportRequest
      – The mailbox export status shows as completed
      – I did not clear the mailbox request
      – Follow the steps in this article
      – Delete mailbox database DB01
      – The mailbox database is deleted without any error
      – Run the cmdlet Get-MailboxExportRequest
      – The mailbox export request still shows as completed

      Your suggestion might work for other readers. Thank you for letting us know.

  5. I have done all checking and the database cannot be deleted even though there are no mailboxes, archives, arbitration, monitoring, etc. it says there are multiple copies, but there is only one server of two that has mailbox related files. I manually deleted the .edb file but the system still thinks there are multiple copies of the database and won’t allow me to delete it.

    1. I updated the article with another way to find the remaining mailboxes. This should help you. I also added how to delete the mailbox database with ADSI Edit (use this as your last option).

Leave a Reply

Your email address will not be published. Required fields are marked *