Site icon Tech blog with tips, tricks and hacks

Purge all disconnected mailboxes in Exchange 2007

If you want to purge all your mailboxes in Exchange 2007, simply follow the below:

1) Open ‘Exchange Management Shell’

2) Add all the disconnected mailboxes into a var by typing the below:

$users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database

3) Purge all the disconnected mailboxes in the previously made var by typing the below:

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

 

Exit mobile version