Task – Get A List Of Disconnected Mailboxes Across All Exchange 2007 Mailbox Servers…

Share & Comment

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

Share & Comment
Subscribe for Updates
Never miss a blog post again
About the author: UC Architect, Blogger, Husband & Dad. I have been in IT for the last 12 years, with Exchange Server becoming the prime area in the last few years. I am active on Experts Exchange & TechNet forums and I am a technical author for SearchExchange.

4 comments… add one

  1. Anonymous

    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!

  2. The command looks ok. What are you trying to achieve?

  3. Christoph Holas

    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

    :-(

  4. Jason Kittrell

    Remove the Foreach-Object cmdlet. It is not needed.

Leave a Comment