Back to Blog

Moving Exchange 2010 Mailboxes to Create White Space

Image of Lasse Pettersson
Lasse Pettersson
Moving Exchange

Exchange admins are from time to time doing mailbox moves.  There could be several reasons for doing this, but the goal is often to create some white space in the mailbox databases.

By moving mailboxes to a different database you would think "holes" will be created in the source database, and that was true until you upgraded the source server to Exchange 2010 Service Pack 1. With Service Pack 1, the behavior changed to leave the data in the source database until it gets cleaned up when the mailbox retention limit is reached. (Remove-StoreMailbox additional information)

The reason for this change is that the mailbox data should be easily accessed in a catastrophic failure before having a proper backup of the target database.

But what if you really want to create some space in the database now?
You could change the mailbox retention timeout to a low number of days or even zero days. But this might not be a suitable solution, and then you will have to clean up the left-overs manually.
The referenced article above states that mailboxes are in a soft-deleted state so they can be found with this command:

Get-MailboxStatistics -Database <databasename> | where {$_.DisconnectReason -eq "SoftDeleted"}

To clean up, you use the cmdlet Remove-StoreMailbox.

To make it work, you can follow these steps:

First, save the mailboxes you want to delete in a variable:

$mbxs = Get-MailboxStatistics -Database databasename_you_want_to_clean_up | where {$_.DisconnectReason -eq “SoftDeleted”}

And then delete them:

$mbxs | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted -Confirm:$false}

This will trigger a process to clean up in the database and you can then create whitespace with this command:

Get-MailboxDatabase -Status | Sort-Object name | Format-Table Name, DatabaseSize, AvailableNewMailboxSpace

Or, for a specific database:

Get-MailboxDatabase -Identity databasename -Status | Format-Table Name, DatabaseSize, AvailableNewMailboxSpace

Remove-StoreMailbox is the same command used for purging deleted mailboxes.

$mbxs = Get-MailboxStatistics -Database databasename_you_want_to_clean_up| where {$_.DisconnectReason -eq “Disabled”}

And then:

$mbxs | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState Disabled -Confirm:$false}

After you have purged disabled or softdeleted mailboxes you should have created some whitespace for mailboxes to grow in without growing the EDB file.

Happy purging.


Exchange-1

Prepare your On-Premises Public Folders for migration

Image of Thomas Stensitzki
Thomas Stensitzki

Many companies use old-style public folders, known as legacy public folders, on Exchange Server...

Read more
person walking in computer server room

Exchange Monitoring: Disk Space

Image of ENow Software
ENow Software

Disk space is vital to the health of an Exchange Server. Without disk, you don’t have email, thus ...

Read more