Viewing Mailbox Sizes and Message Counts






Viewing Mailbox Sizes and Message Counts

A common task is to look at an Exchange server and determine the sizes and counts of messages on the server for all mailboxes. The following code shows how simple this is to do:

    ' This code enumerates mailbox sizes and message counts.
    Option Explicit
    Dim strComputer, objWMI, objMbxs, objMbx
    ' ------ SCRIPT CONFIGURATION ------
    strComputer = "<Exchange Server>" 'e.g. ExchServer2
    ' ------ END CONFIGURATION ---------

    Set objWMI = GetObject("winmgmts:\\" & strComputer & _
                           "\root\MicrosoftExchangeV2")
    Set objMbxs = objWMI.ExecQuery("Select * from Exchange_Mailbox",,48)
    For Each objMbx In objMbxs
      WScript.Echo objMbx.MailBoxDisplayName & " " & objMbx.size & "KB  " _
                   & objMbx.TotalItems & " items"
    Next
    WScript.Echo "Script completed successfully."

This script is very similar to the script to enumerate disconnected mailboxes. The same basic process is used; we have simply changed the initial query to select the record set to enumerate through. There are actually several properties that can be displayed this way. Figure lists the properties and their descriptions.

Exchange_Mailbox properties

Property

Description

LegacyDN

legacyDN of the mailbox. This matches the legacyExchangeDN attribute of the user object in Active Directory.

MailboxGUID

Indicates the globally unique identifier (GUID) that links the mailbox to a user in Active Directory. This value is also populated in the user's Active Directory object as msExchMailboxGuid.

ServerName

Name of the server the mailbox resides on.

StorageGroupName

Indicates the name of the storage group that contains the mailbox.

StoreName

Indicates the name of the message database (MDB) that contains the mailbox.

AssocContentCount

Indicates the total number of messages associated with the mailbox folders.

DateDiscoveredAbsentInDS

Indicates when the store detected that the mailbox no longer had a corresponding user entry in Active Directory; i.e., when the mailbox was disconnected.

DeletedMessageSizeExtended

Indicates the cumulative size of all deleted messages that are still being retained according to retention policy settings.

LastLoggedOnUserAccount

Indicates the account name last used to log onto the mailbox. Note that this doesn't necessarily mean an interactive logon to the mailbox messages; this could be from someone viewing a calendar entry or other innocuous access.

LastLogoffTime

Indicates the time that the last user logged off. See note for LastLoggedOnUserAccount.

LastLogonTime

Indicates the time that the last user logged on. See note for LastLoggedOnUserAccount.

Size

Indicates cumulative size of all of the messages in the mailbox in bytes.

StorageLimitInfo

Contains the storage limit settings on the mailbox.

TotalItems

Indicates the total number of messages in a mailbox.




 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows