Sunday, November 2, 2008

Removing Disconnected Mailboxes in Exchange 2007

Whenever we disable ore remove any mailbox, by default it goes in disconnected state and can be viewed in disconnected mailboxes view in EMC.

For disabling any account you can run following command

You can also remove any account without providing confirm parameter. Confirm parameter will permanently delete the account and this account will not be visible in disconnected mailboxes view
Remove-Mailbox -Database <Database-Name>

If your account is not visible in disconnected mailboxes view you can confirm it by running following command

Clean-mailboxdatabase -identity "<server name>\<storage group name>\<mailbox database name>"

If you want to permanently delete your account then you have to run this command Remove-Mailbox -Database <Database-Name> -StoreMailboxIdentity <MailboxGuid> -confirm:$false

For finding GUID you have to run this command

Get-MailboxStatistics -server <server name> | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid

You have to copy the GUID and then paste in the above command for permanently deleting any account

If you want to remove all disconnected mailboxes then you have to first run following command

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

Now you have all users in Variable users, you can run following command

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


Gobli said...

tip about removing disconnected mailboxes helped a lot :)

Anonymous said...

Excellent!!!Thanks a lot!!!Help me this a lot!!!I love you!!!!

Anonymous said...

I would like to thnkx for the efforts you have put in writing this blog. I am hoping the same high-grade blog post from you in the upcoming as well. In fact your creative writing abilities has inspired me to get my own blog now. Really the blogging is spreading its wings quickly. Your write up is a good example of it.

Anonymous said...

Thanks for the article. It saved my job!