cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing out deleted mailboxes

Rob_Wilcox1
Level 6
Partner

I've been doing a lot of testing just recently with Exchange 2010 (and Archive Shuttle and Enterprise Vault).  One of the things that I have needed to do is to create hundreds of mailboxes, populate them with the data, do some testing, then delete all the mailboxes and actually get rid of them.

In Exchange 2010 deleted mailboxes are not quite gone.  There are a couple of extra steps which are needed.  Let's see:

Firstly, my Exchange Management Console looks a bit like this:

1.png

But I want them all to be gone.  I can right click and choose ‘Remove’:

2.png

But, check here in the management console:

3.png

So now fromthe Exchange Management Shell I would run:

$mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database

Followed by:

$mailboxes | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }

And now back in the Exchange Management Console it looks like this:

4.png

Happy :)