Skip to Main Content
Active Directory, 3rd Edition
book

Active Directory, 3rd Edition

by Joe Richards, Robbie Allen, Alistair G. Lowe-Norris
January 2006
Beginner content levelBeginner
832 pages
27h 52m
English
O'Reilly Media, Inc.
Content preview from Active Directory, 3rd Edition

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. Table 24-4 lists the properties and their descriptions.

Table 24-4. 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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Active Directory, 4th Edition

Active Directory, 4th Edition

Brian Desmond, Joe Richards, Robbie Allen, Alistair G. Lowe-Norris
Active Directory, Second Edition

Active Directory, Second Edition

Robbie Allen, Alistair G. Lowe-Norris

Publisher Resources

ISBN: 0596101732Supplemental ContentErrata Page