How to remove all Disconnected Mailboxes in Exchange Server 2010
WARNING this will remove ALL disconnected mailboxes, make sure you actually want to do this before proceeding.
WARNING this will remove ALL disconnected mailboxes, make sure you actually want to do this before proceeding.
1. On one of the Exchange servers > Start > All
Programs > Microsoft Exchange Server 2010 > Exchange Management
Shell.
2. [PS]
$mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database
3. [PS]
2. [PS]
$mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database
3. [PS]
$mailboxes | ForEach { Remove-Mailbox -Database $_.Database
-StoreMailboxIdentity $_.MailboxGuid -confirm:$false }
Errors Note:
Problem:
Mailbox
"66278a17-48f7-4926-9646-93a3fc34c34f" doesn't exist on database
"JCH-MD015".
+
CategoryInfo :
NotSpecified: (0:Int32) [Remove-Mailbox], ManagementObjectNotFoundException
+
FullyQualifiedErrorId :
17B93A05,Microsoft.Exchange.Management.RecipientTasks.RemoveMailbox
Solution:
[PS]
[PS]
Get-MailboxStatistics -Database
"database" | where {$_.DisconnectReason -eq "SoftDeleted"}
| foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid
-MailboxState SoftDeleted}
Confirm
Are you sure you want to perform
this action?
[Y] Yes [A] Yes to All
[N] No [L] No to All [?] Help (default is "Y"): Y
Problem:
Pipeline not executed because a
pipeline is already executing. Pipelines cannot be executed concurrently.
+
CategoryInfo :
OperationStopped:
(Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [],
PSInvalidOperationException
+
FullyQualifiedErrorId : RemotePipelineExecutionFailed
Solution
[PS]
Get-MailboxStatistics -Database
"database" | Where-Object {$_.DisconnectDate -Notlike $NULL} | FL
DisplayName, DisconnectDate, MailboxGuid >
C:\Temp\database.txt
[PS]
Remove-StoreMailbox -Database
"database" -Identity "John Doe" -MailboxState
SoftDeleted
Confirm
Are you sure you want to perform
this action?
Removing mailbox "John Doe" on database "database".
[Y] Yes [A] Yes to All
[N] No [L] No to All [?] Help (default is "Y"): Y