Get all disconnected mailboxes
Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid
Remove a single disconnected mailbox
Remove-Mailbox -Database -StoreMailboxIdentity -confirm:$false
Remove all disconnected mailboxes
$users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database
Then all disconnected mailboxes are in a variable and you run following cmdlet to remove mailboxes
$users | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }
No comments:
Post a Comment