Daily Exchange Mailbox Size Report

There are a plethora of software packages out there to report against your Exchange Infrastructure and many of them are great.  I’ve worked with several in the past.  However, if you want just a simple report for mailbox sizes, and you have access to a SQL Server, you can write your own process.

My script does the following:

  1. Check to see if the Exchange Snapin is loaded and loads it if necessary.
  2. Build up a connection to the SQL Server.
  3. Cycle through each Mailbox Server in your environment.
  4. Cycle through each Mailbox Database in your environment for each Server.
  5. Cycle through each Mailbox for each Mailbox Database.
  6. Execute a single SQL Insert command to add an entry to the table in question.
  7. Finally, it closes the SQL Connection and disposes of it.

First, let’s build the SQL Table.  Assuming that you have a database where you have proper credentials, you can just run the following SQL script to create the “MailboxStats” Table.

Then all you need to do is run the following script on a scheduled basis. I’ve found that even daily entries do not grow the database to insane sizes too quickly.

Once the script is run, each record will look something like this:

Id RunDate MailboxGuid DisplayName ServerName DatabaseName IsArchiveMailbox DeletedItemCount DeletedItemSize ItemCount MailboxSize
20501 2014-02-25 00:00:00.000 69633637-b359-4654-8dad-eee2dab98502 Sparenberg, Kevin M. MBXSERVER02v DB02 0 10069 40603360 63191 1249148371
20502 2014-02-25 00:00:00.000 38c4add6-4dad-486a-afae-0770136fafd3 Sparenberg, Kevin M. MBXSERVER02v DB05 1 652 1879831 11985 264359378


You can see that there are separate records for the Primary and Archive Mailbox. This script should run in either Exchange 2010 or Exchange 2013, though I’ve not had opportunity to check on the latter as yet.

The script is pretty straight forward, but if you have any questions, all you need to do is ask.

Until next time, Ramblers.

2 thoughts on “Daily Exchange Mailbox Size Report

  1. Helpful article, thanks for the wonderful information, that provides the script related to exchange mailbox size report, I tested this tool from http://www.lepide.com/exchange-reporter/ that allows to generate of exchange mailbox reports as per requirement and view status of scheduled reports (success or failure). This tool helps to analyze mailboxes, attachment size, mailbox folder, and Outlook Web access (OWA) with the help of the reports generated and filter the reports up to the granular level.

Leave a Comment