Get-MailboxStatistics for Exchange 2003

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 2007Exchange 2003
DeletedItemCount*Not available*
ObjectClassCan be assumed to be Mailbox
DatabaseComposed of Server, Storage Group and Store
IdentityMailboxGuid (repeat of above included for pipeline)
IsValid*Not available*
OriginatingServerSame 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.

Get-2003MailboxStatistics | Format-Table MailboxDisplayName, TotalItems, StorageLimitStatus, LastLogonTime

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

With a Mailbox Display Name Get-2003MailboxStatistics "Chris Dent" # With a Legacy Exchange DN ("-Identity" itself is optional) Get-2003MailboxStatistics -Identity "/O=SomeOrg/OU=AdminGroup/CN=RECIPIENTS/CN=Someone" # For a single Mailbox Database Get-2003MailboxStatistics -Database "Mailbox Database" # For a different server Get-2003MailboxStatistics -Server "ExchangeServer02"

Get-MailboxStatistics for Exchange 2003

function Get-2003MailboxStatistics { param( [String]$Identity = "", [String]$Server = $env:ComputerName, [String]$Database = "" ) $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'" } Get-WMIObject Exchange_Mailbox -Namespace "root/MicrosoftExchangeV2" -ComputerName $Server -Filter $Filter | Select-Object ` AssocContentCount, @{n='DateDiscoveredAbsentInDs';e={ if ($.DateDiscoveredAbsentInDs -ne $null) { [Management.ManagementDateTimeConverter]::ToDateTime($.DateDiscoveredAbsentInDs) } }}, MailboxDisplayName, TotalItems, LastLoggedOnUserAccount, @{n='LastLogonTime';e={ if ($.LastLogonTime -ne $null) { [Management.ManagementDateTimeConverter]::ToDateTime($.LastLogonTime) } }}, @{n='LastLogoffTime';e={ if ($.LastLogoffTime -ne $null) { [Management.ManagementDateTimeConverter]::ToDateTime($.LastLogoffTime) } }}, LegacyDN, @{n='MailboxGuid';e={ ([String]$.MailboxGuid).ToLower() -replace "{|}" }}, @{n='ObjectClass';e={ "Mailbox" }}, @{n='StorageLimitStatus';e={ switch ($.StorageLimitInfo) { 1 { "BelowLimit"} 2 { "IssueWarning" } 4 { "ProhibitSend" } 8 { "NoChecking" } 16 { "MailboxDisabled" } } }}, DeletedMessageSize, Size, @{n='Database';e={ "$($.ServerName)$($.StorageGroupName)$($.StoreName)" }}, ServerName, StorageGroupName, StoreName, @{n='Identity';e={ ([String]$.MailboxGuid).ToLower() -replace "{|}" }} }