All of us are familiar with the “Disconnected Mailbox” node in Exchange 2007 management console and the frustration of not finding all the disconnected mailboxes in the node, as we would expect. It will appear eventually or we have to run a Clean-MailboxDatabase cmdlet to force exchange to find all the disconnected mailboxes.
How can we find the list of all disconnected mailboxes using shell? Quite easy! Run
Get-MailboxStatistics | Where-Object {$_.DisconnectDate –notlike ‘’} | select Displayname, Database
This command has to be run from the exchange server itself and will work fine. But, what if you work for a large enterprise who has a reasonable number of mailbox servers? In most of the bigger companies, you would have dedicated management servers where you have all the tools loaded. In this case, we need to get a list of all our mailbox servers and pipe them to the above command in a loop. The command below will give you a list of all disconnected mailboxes on all your mailbox servers. You can run the command from an exchange server itself or from any of your management servers which has the exchange tools installed.
Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}}
You can get the desired output by piping the above command with the required properties. For example,
Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics -Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, database
As usual, you can export the results to a csv or txt file.
Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics -Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, database | export-csv c:mailboxes.csv
please try the below cmd to list all the disconnected mailboxes in the entire organization level..
[PS] E:\scripts\CatalogRemoveScripts>Get-MailboxDatabase | Get-MailboxStatistics | where { $_.DisconnectDate -ne $null
}| select DisplayName,MailboxGuid,Database,DisconnectDate >>C:\Users\bashashadm\dis.csv
Remove the Foreach-Object cmdlet. It is not needed.
Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics -Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, database | export-csv c:mailboxes.csv
brings up the following errors:
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power…tHelperRunspace:ExecutionCmdletHelperRunspace) [], PSInvalidOperationException
+ FullyQualifiedErrorId : RemotePipelineExecutionFailed
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power…tHelperRunspace:ExecutionCmdletHelperRunspace) [], PSInvalidOperationException
+ FullyQualifiedErrorId : RemotePipelineExecutionFailed
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power…tHelperRunspace:ExecutionCmdletHelperRunspace) [], PSInvalidOperationException
+ FullyQualifiedErrorId : RemotePipelineExecutionFailed
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power…tHelperRunspace:ExecutionCmdletHelperRunspace) [], PSInvalidOperationException
+ FullyQualifiedErrorId : RemotePipelineExecutionFailed
:-(
The command looks ok. What are you trying to achieve?
Hi there,
what should be replaced in this command
Get-MailboxStatistics | Where-Object {$_.DisconnectDate –notlike ‘’}
instead of $_.DisconnectDate –notlike ‘’? How exactly is should look like? Many thx!