Thursday, September 29, 2011

Removing Mailboxes in Exchange 2007

In Exchange 2007 they seemed to have removed ways to easily get to features an Exchange admin uses regularly. Settings such as, database clean-up, disconnected mailbox removal and so on.



I needed to remove a disconnected mailbox since her account was sucking up almost half a gig on our database. Here are the steps to do that.

1) Open the Exchange Management Shell.

2)Type this to list all Disconnected Mailboxes:


Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid
Special Note: You can not delete a mailbox that is currently connected to an account. You need to first delete the account in Active Directory. After that exchange will mark that particular mailbox for deletion and then it will show up in the list that this command shows. If you want to delete an account but not mark the mailbox for deletion , be sure to uncheck the box in the window that appears when you are deleting the account.

3) This next command deletes all disconnected mailboxes.
 
Get-MailboxStatistics -database "server\database" | where {$_.disconnectdate -ne $null} | foreach {Remove-mailbox -database $_.database -storemailboxidentity $_.mailboxguid}


4) Run this command to check mailboxes as well as their sizes to be sure that mailbox has been removed.


Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="
TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount 

No comments:

Post a Comment