Thursday, 13 March 2008

Exchange 2007 Powershell Disconnected Mailbox

Remove Disconnected Mailboxes in Exchange 2007

List all Disconnected Mailboxes
Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid


Remove single mailbox
Remove-Mailbox -Database -StoreMailboxIdentity -confirm:$false

Remove all at the same time
$users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid




Remove from all databases:

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

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

No comments: