Script Lets You Easily Review Mailbox Data

MailboxSizes.vbs retrieves mailbox data from Exchange 2003 servers and outputs that data to an XML file for easy analysis in Excel or Access.

Readers

September 24, 2006

2 Min Read
ITPro Today logo in a gray background | ITPro Today


I have to regularly perform all kinds of analyses on the mailboxes in our Exchange Server 2003 machine. To make this task easier, I created a script named MailboxSizes.vbs, which Listing 1 shows. This script retrieves mailbox data about all the mailboxes on all the mailbox stores from an Exchange 2003 server, then outputs this information to an XML file. You can then import the XML file into Microsoft Excel or Microsoft Access for analysis.

MailboxSizes.vbs uses Windows Management Instrumentation's (WMI's) Exchange_Mailbox class to retrieve the display name, size, and total number of messages in each mailbox. The script also obtains the name of the store in which each mailbox resides.

To use MailboxSizes.vbs, you need to configure one line. In the code at callout B in Listing 1, replace Server1 with the name of your Exchange server. Then, run the command

MailboxSizes.vbs 

on that Exchange server. MailboxSizes.vbs creates the XML file in the directory in which the script is located.

If you have several Exchange servers, you can adapt MailboxSizes.vbs so that you can easily schedule the script to run as a task. With the following changes, you don't need to edit the script each time you want to use it on a different server. First, replace the code at callout A in Listing 1 with the code that Listing 2 shows. Then, in the code at callout B, replace Server1 with the variable name servername. To run the adapted script, you use the command

CScript mailboxsizes.vbs /outfile:filename.xml /server:servername

where filename is the pathname to the XML file and servername is the name of the Exchange server on which you want to run the script. (Although this command appears on several lines here, you would enter it on one line in the command-shell window.)

You can also adapt MailboxSizes.vbs so that it retrieves other types of mailbox information. For example, you can use the Exchange_Mailbox class's StorageLimitInfo property to retrieve a mailbox's storage limit settings. For information about how to use this and other properties, see the Exchange_ Mailbox Class Web page.

You can download MailboxSizes.vbs from the Exchange & Outlook Administrator Web site. This script is for use on servers running Exchange 2003, with WMI and Windows Script Host (WSH) 5.6 installed.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like