Failure: This mailbox database contains one or more mailboxes

Symptom:

Some Exchange databases cannot be removed because of error message states there are mailboxes in the database.

Get-MailboxDatabase -Server Server1 | Remove-MailboxDatabase

Result:
This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, public folder mailboxes orarbitration mailboxes. To get a list of all mailboxes in this database, run the command Get-Mailbox –Database . 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 -Archive. To get a list of all public folder mailboxes in this database, run the command Get-Mailbox -Database -PublicFolder. To get a list of all arbitration mailboxes in this database, run the command Get-Mailbox -Database -Arbitration.

[Remove-MailboxDatabase], AssociatedUserMailboxExistException    + FullyQualifiedErrorId : [Server=Server1,RequestId=26a04655-6a66-4990-9a07-7599f69850d0]….

Resolution:

To identify the mailboxes that are still in the mailbox database use the –Verbose switch with Remove-MailboxDatabase cmdlet

Get-MailboxDatabase -Server Server1 | Remove-MailboxDatabase -Verbose

Result:
VERBOSE: [12:28:53.599 GMT] Remove-MailboxDatabase : Runspace context: Executing user:
Contoso.com/Admins/Administrator, Executing user organization: , Currentorganization: , RBAC-enabled: Enabled.
VERBOSE: [12:28:53.599 GMT] Remove-MailboxDatabase : Active Directory session settings for ‘Remove-MailboxDatabase’ are: View Entire Forest: ‘False’, Default Scope: ‘Contoso.com’, Configuration Domain Controller: ‘DC1.Contoso.com’, Preferred Global Catalog: ‘DC1.Contoso.com’, Preferred Domain Controllers: ‘{ DC1.Contoso.com }’
VERBOSE: [12:28:53.599 GMT] Remove-MailboxDatabase : Beginning processing Remove-MailboxDatabase
VERBOSE: [12:28:53.599 GMT] Remove-MailboxDatabase : Instantiating handler with index 0 for cmdlet extension agent “Admin Audit Log Agent”.
VERBOSE: [12:28:53.615 GMT] Remove-MailboxDatabase : Current ScopeSet is: { Recipient Read Scope: {{, }}, Recipient Write Scopes: {{, }}, Configuration Read Scope: {{, }}, Configuration Write Scope(s): {{, }, }, Exclusive Recipient Scope(s): {}, Exclusive Configuration Scope(s): {} }
VERBOSE: [12:28:53.615 GMT] Remove-MailboxDatabase : Searching objects “DAG-DB1” of type “MailboxDatabase” under the root “$null”.
VERBOSE: [12:28:53.630 GMT] Remove-MailboxDatabase : Previous operation run on domain controller’DC1.Contoso.com’.
VERBOSE: [12:28:53.646 GMT] Remove-MailboxDatabase : Verifying that there is no associated mailbox user or move request on the mailbox database “DAG-DB1”.
VERBOSE: [12:28:53.646 GMT] Remove-MailboxDatabase : Mailbox with DistinguishedName “CN=Doe\,John,OU=Users,DC=Contoso,DC=com” is still present in this database.
VERBOSE: [12:28:53.661 GMT] Remove-MailboxDatabase : Admin Audit Log: Entered Handler:OnComplete.
This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, public folder mailboxes orarbitration mailboxes. To get a list of all …

Note:

The returned DistinguishedName will identify the Active Directory account associated with the mailbox still present in the database.
If the account belowngs to a user mailbox use the Get-Mailbox cmdlet to find out whether it is a primary mailbox or an archive mailbox (or both).