Removing an Exchange Database is not as simple as clicking on a delete button. Exchange is tied together with Active Directory, a mailbox and other objects have footprints there and if a database is removed that still has any objects in it, that would leave AD in an inconsistent state. We need to make sure to remove any dependencies from AD before proceeding with the removal. That means moving away ALL the mailboxes, from the database, or deleting, disconnecting the mailboxes if they are not needed anymore. Also, if there are ANY kind of move requests associated with the mailbox database, those needs to be removed too. This also applies to completed move requests! After removing the databases from a server, the Exchange server can also be uninstalled. That procedure removes the server from the machine and also from AD.
1. Check databases hosted on the mailbox server that need to be removed
Here we have only DB03 to remove.
PS C:\> Get-MailboxDatabase -Server MB3 Name Server Recovery ReplicationType ---- ------ -------- --------------- DB03 MB3 False None PS C:\>
Trying to do so fails, as we still have mailboxes living in the database. In our example we decided to keep them, so we move all away from the server. We could also remove or disconnect the mailboxes if they don't have any content we need to keep.
2. List all the mailboxes in the database
PS C:\> Get-Mailbox -Database DB03 Name Alias ServerName ProhibitSendQuota ---- ----- ---------- ----------------- Ashlyn Velazquez Ashlyn.Velazquez mb3 Unlimited Ashtyn Duran Ashtyn.Duran mb3 Unlimited Ayana Bryan Ayana.Bryan mb3 Unlimited Ashton Ortega Ashton.Ortega mb3 Unlimited PS C:\> Get-Mailbox -Database DB03 -Arbitration PS C:\> Get-Mailbox -Database DB03 -Archive PS C:\> Get-Mailbox -Database DB03 -PublicFolder PS C:\> Get-Mailbox -Database DB03 -AuditLog
3. Clear the database
We can either move the mailboxes away from the database or remove them. See examples of both below.
Move mailboxes away from the database
PS C:\> Get-Mailbox -Database DB03 | New-MoveRequest -TargetDatabase DB01 -Priority highest PS C:\> Get-Mailbox -Database DB03 -Arbitration | New-MoveRequest -TargetDatabase DB01 -Priority highest PS C:\> Get-Mailbox -Database DB03 -Archive | New-MoveRequest -TargetDatabase DB01 -Priority highest PS C:\> Get-Mailbox -Database DB03 -PublicFolder | New-MoveRequest -TargetDatabase DB01 -Priority highest PS C:\> Get-Mailbox -Database DB03 -AuditLog | New-MoveRequest -TargetDatabase DB01 -Priority highest
Remove mailboxes (only non-arbitration mailboxes!)
PS C:\> Get-Mailbox -Server MB3 | Disable-Mailbox PS C:\> Get-Mailbox -Database DB03 -Arbitration | New-MoveRequest -TargetDatabase DB01 -Priority highest PS C:\> Get-Mailbox -Database DB03 -Archive | Disable-Mailbox -Archive PS C:\> Get-Mailbox -Database DB03 -PublicFolder | Disable-Mailbox -PublicFolder PS C:\> Get-Mailbox -Database DB03 -AuditLog | Disable-Mailbox
4. Check move status
PS C:\> Get-MoveRequest | Get-MoveRequestStatistics
5. Remove the Database
Remove moverequests if present:
Get-MoveRequest | ?{$_.Status -eq 'Completed'} | Remove-MoveRequest -Confirm:$false
When done, remove the database:
PS C:\> Remove-MailboxDatabase DB03
6. Demote Mailbox Server
If needed, the Exchange deployment can be removed using the MS Programs and Features snapin (appwiz.cpl)
Comments