When you try to remove a Microsoft Exchange Server database by running the Remove-MailboxDatabase PowerShell cmdlet, you receive an error message that resembles the following message:
This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, public folder mailboxes, arbitration mailboxes, or audit mailboxes. To get a list of all mailboxes in this database, run the command Get-Mailbox -Database <database ID>... To disable a non-arbitration mailbox so that you can delete the mailbox database, run the command Disable-Mailbox <mailbox ID>... Audit 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 Get-Mailbox -AuditLog | Disable-Mailbox...
Cause
Exchange Server prevents users from removing a database that contains an enabled mailbox that's one of the following mailbox types:
User mailbox
Archive mailbox
Public folder mailbox
Arbitration mailbox
Audit log mailbox
Resolution
Note
Run the following PowerShell cmdlets in the Exchange Management Shell (EMS).
You can't move a mailbox to another database in Exchange Server if the database that currently hosts the mailbox is the last one in your organization. You can only disable or remove the mailbox.
To fix the issue, follow these steps:
Set the scope of the EMS session to the entire forest in Active Directory Domain Services by running the following PowerShell cmdlet:
Set-ADServerSettings -ViewEntireForest $true
Move, disable, or remove any enabled user mailboxes in the database:
Get a list of enabled user mailboxes by running the following PowerShell commands:
$userMailboxes = Get-Mailbox -Database <database name> | where {$_.IsMailboxEnabled}
$userMailboxes
If the list is empty, go to step 3.
Select any of the following options:
To move the user mailboxes to another database, run the following PowerShell cmdlet:
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.