Recipe17.17.Viewing Mailbox Sizes and Message Counts


Recipe 17.17. Viewing Mailbox Sizes and Message Counts

Problem

You want to view the sizes and message counts of all mailboxes on a server.

Solution

Using a graphical user interface

  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the mailboxes container of the server, storage group, and database where you want to view mailboxes.

  3. In the right pane, scroll down through the list of mailboxes, noting the Size and Total Items columns.

Using VBScript
' This code displays all mailboxes and their sizes ' ------ 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."

Discussion

Mailbox sizes and message counts are items on Exchange systems that administrators routinely want to know about for the purposes of reporting and metrics. Administrators want to know if their mail system is balanced and if users are spread across the mailbox stores evenly. Knowing the number of users and the size of their mailboxes in each mailbox store, the administrator can make better decisions about where new user mailboxes should be placed or if some leveling of mailboxes is required.

Viewing mailbox details in the ESM requires Exchange View Admin role access. However, in order to do this with a script, the WMI provider requires local administrator permissions on the Exchange server. See the Discussion for Recipe 17.7.


Using a graphical user interface

Click on the header of each of the columns displayed in the right pane of the ESM to sort by that value.

Using VBScript

This script can be modified to show several things for mailboxes. Some of the more notable items besides Size and Items are LastLogonTime, LastLoggedOnUserAccount, and DateDiscoveredAbsentInDS. Please reference the Exchange 2003 SDK for a complete list of items available in the Exchange_Mailbox class.

Since this script uses Exchange WMI extensions, it can be run from any machine that has WMI; the machine does not have to have the Exchange Management Tools loaded.


See Also

Exchange Server 2003 SDK: WMI Reference



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net