Get the Exchange 2010 DB whitespace back

Exchange-logo
For exchange administrators it is sometime necessary to see how our Exchange databases are doing. You don't want that the database and transaction log on the datastores run out of disk space.

Most of the time I want to see the blank space that is within a database. This blank space is sometimes called:
  • Free space
  • Free database pages
  • Available Mailbox Space
  • White space

Checking White Space in Exchange 2010

Get the Whitespace from all the databases, run the following command:
 Get-MailboxDatabase -Status | Sort-Object availablenewmailboxspace | ft name,databasesize,availablenewmailboxspace -auto 
Exchange-DB-Whitespace

Show all softdeleted and disabled mailboxes in Exchange 2010

After you choose the DB you want to clear the whitespace, please check the softdeleted and disabled mailbox accounts per database with the following command:
 Get-MailboxStatistics -Database "DB1" | Where-Object {$_.DisconnectDate -Notlike $NULL} | Format-Table DisplayName, DisconnectDate, MailboxGuid, DisconnectReason –Wrap  
Exchange-list-softdelete-disabled-mailbox

How to delete disabled mailboxes in Exchange 2010

To get the whitespace back, you want to delete the disabled mailbox accounts from the database you show earlier. With the following account you will perform a delete action, only for disabled mailboxes:
 $Mailboxes = Get-MailboxStatistics -Database "DB1" | where {$_.DisconnectReason -eq “Disabled”}  
 $Mailboxes | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState Disabled }  
remove-exchange-disabled-mailbox
Check the Mailbox ID with the show command earlier. To check if you delete the right mailbox account.

How to delete softdeleted mailboxes in Exchange 2010

You can also choose to delete all the softdeleted mailbox account with the following command:
 $Mailboxes = Get-MailboxStatistics -Database "DB1" | where {$_.DisconnectReason -eq “SoftDeleted”}  
 $Mailboxes | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}  

Comments

Popular posts from this blog

Error when opening LCM via PRISM

Azure AD Connect DB corrupt