Exchange 2007/2010/2013 List and Remove Disconnected Mailboxes
Exchange 2007/2010/2013 Anzeigen und entfernen gentrennte Mailboxen
Depending on what intervall you have on matintenance and cleanup 14/30. Even set to “zero” this mayx take some time to remove disconnected Mailboxes.
Here is how to speed things up:
List all users in a certain OU of Active Directory:
get-mailbox -resultsize unlimited | where { $_.Database -eq “SERVER1\First Storage Group\MDB01” -AND $_.OrganizationalUnit -eq “cutsomer.ch/Infra/User/Deactivated”}
Removes Soft Deleted so the get deleted HARDDELETED after the X days/ghours mentioned in your settings
Get-MailboxStatistics -Database “MDB01” | where {$_.DisconnectReason -eq “SoftDeleted”} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}
Let’s say all the movers you have cleaned up are on Database “MDB01”. It’s a good idea to move the disabled users mailboxes to a own storage group so they don’t speed down the rest of the active mailboxes.
List all the IDENTITY of the MAILBIOXED on MDB01
Get-MailboxStatistics -Database “MDB01” | Where-Object {$_.DisconnectDate -Notlike $NULL} | FL DisplayName, DisconnectDate, MailboxGuid
Remove-Mailbox -Database “MDB01” -StoreMailboxIdentity def4aabd-2156-5857-858f-470efc3e6f28
Please notice the “clean-mailboxdatabase” command if a Mailbox does not shwo up under Disconncted (Getrennte):
http://technet.microsoft.com/en-us/library/bb124076(v=exchg.141).aspx
A connected mailbox has two parts: the mailbox object in the Exchange store and the user object with Exchange properties in Active Directory. A disconnected mailbox is the mailbox object in the Exchange store, but it isn’t connected to a user object in Active Directory. To disconnect a mailbox, use the Disable-Mailbox cmdlet. To disconnect a mailbox and remove the user object from Active Directory, use the Remove-Mailbox cmdlet. If you want to permanently remove a mailbox object from the Exchange store, use the Remove-Mailbox cmdlet.
If you want to reconnect a disconnected mailbox to an Active Directory user account, use the Connect-Mailbox cmdlet.
Under normal circumstances, it isn’t necessary to run the Clean-MailboxDatabase cmdlet because a mailbox is marked as disconnected immediately after the Disable-Mailbox or Remove-Mailbox command completes. If you used the Disable-Mailbox cmdlet or the Remove-Mailbox cmdlet while the Microsoft Exchange Information Store service was stopped, or if a mailbox was disabled by an external means other than the Disable-Mailbox cmdlet or Remove-Mailbox cmdlet, you may want to use the Clean-MailboxDatabase cmdlet to scan for disconnected mailboxes.
You need to be assigned permissions before you can run this cmdlet. Although all parameters for this cmdlet are listed in this topic, you may not have access to some parameters if they’re not included in the permissions assigned to you. To see what permissions you need, see the “Mailbox Database permissions” entry in the Mailbox Permissions topic.