Using PowerShell to create a version of Get-MailboxStatistics for Exchange 2003.

Get-MailboxStatistics returns a set of information about a mailbox for Exchange 2007. It is possible to retrieve roughly the same information using WMI for Exchange 2003.

The differences

The following table notes the differences in property names between Exchange 2003 and Exchange 2007.

Exchange 2007 Exchange 2003
AssociatedItemCount AssocContentCount
DeletedItemCount Not available
DisconnectDate DateDiscoveredAbsentInDS
DisplayName MailboxDisplayName
ItemCount TotalItems
ObjectClass Can be assumed to be Mailbox
StorageLimitStatus StorageLimitInfo
TotalDeletedItemSize DeletedMessageSizeExtended
TotalItemSize Size
Database Composed of Server, Storage Group and Store
DatabaseName StoreName
Identity MailboxGuid (repeat of above included for pipeline)
IsValid Not available
OriginatingServer Same as ServerName

In addition to these the MailboxGuid attribute is formatted slightly differently. The MailboxGuid is enclosed in curly braces, {}, these are stripped in the code (or added when a search is being performed using a GUID)

No formatting is applied to the output. The output from this function can be made to look like the Exchange 2007 version of Get-MailboxStatistics by using Format-Table.

This is the code for the function, it is not as flexible as the Exchange 2007 version with regard to pipelines, but it should accept simple input and work in much the same way otherwise.

Usage examples

Get-MailboxStatistics for Exchange 2003

10 Comments

  1. Thanks! I was looking for pretty much this exact script; this saved me a LOT of time in writing it. One observation; the “-Database” switch was causing it to fail, until I made a change. On line 10 I changed:

    $Filter = “$Filter AND StoreName=’$Database ($Server)'”

    to:

    $Filter = “$Filter AND StoreName=’$Database'”

    That’s all it took in my environment (Exchange 2003 SP2 on Server 2003 Enterprise 32 bit.)

    Reply

  2. Thanks for that, overlooked the default naming for stores on my installation of 2003.

    Chris

    Reply

  3. No matter what switch I use the script just returns me to the cmd promp without displaying any data. What am I doing wrong ?

    Reply

  4. the Query Above works just fine and I was able to get your script to function after removing the following section (only -server functions which meets my needs)

    $Filter = “ServerName=’$Server'”
    if ($Database -ne “” ) {
    $Filter = “$Filter AND StoreName=’$Database'”
    }
    if ($Identity -ne “”) {
    $Filter = “$Filter AND (MailboxGuid='{$Identity}’ OR LegacyDN=’$Identity'”
    $Filter = “$Filter OR MailboxDisplayName=’$Identity’)”
    }

    Reply

  5. excellent work, thanks

    Reply

  6. Very much appreciated.

    Reply

  7. Chris,

    Awesome script!

    Reply

  8. What would cause the script to return to the powershell prompt with no output.

    When i run this Get-WMIObject -ComputerName “YourServer” -Namespace “root/MicrosoftExchangeV2″ -Class “Exchange_Mailbox” and change the name of yourserver to the actual name i get a response of >>.

    Reply

    • It means it’s waiting to see the rest of the command. If your input was intentionally multi-line hitting return again will execute. Otherwise something in the command is not finished, could be an extra “, or an unfinished array (item, item,) and so on.

      Chris

      Reply

  9. Pingback: Question for the exchange gurus!

Leave a Reply

Your email address will not be published. Required fields are marked *