One of the Exchange Server administration tasks I perform almost every day is creating mailbox size reports. There are a few different reasons that I create these reports, such as planning a mailbox migration project, responding to a storage capacity alert for a particular database, or providing a specific team of people with a report of their mailbox sizes.
Now it is pretty easy to get the sizes for Exchange mailboxes and to handle the formatting of the Exchange 2010 mailbox statistics so that they are easier to perform calculations on, but it gets a bit boring running those commands day after day.
Even worse, after running the commands to create a CSV report I still had to open that in Excel, remove the unwanted details, use Excel formulas to convert the values from bytes to megabytes, sort them into order, and so on. Again not difficult, just boring after doing it hundreds of times.
So I created a PowerShell script, Get-MailboxReport.ps1, to do all of the heavy lifting for me, and I'm sharing that script with you here.
Let's take a look at how the script works. Here is a video to demonstrate:
I've included help information within the script itself so you can use Get-Help to discover how to run the script.
[PS] C:\Scripts\demo>Get-Help .\Get-MailboxReport.ps1
Get-MailboxReport.ps1 - Mailbox report generation script.
C:\Scripts\demo\Get-MailboxReport.ps1 [-database ] 
C:\Scripts\demo\Get-MailboxReport.ps1 [-file ] 
C:\Scripts\demo\Get-MailboxReport.ps1 [-server ] 
C:\Scripts\demo\Get-MailboxReport.ps1 [-mailbox ] 
C:\Scripts\demo\Get-MailboxReport.ps1 [-all] 
Generates a report of useful information for
the specified server, database, mailbox or list of mailboxes.
Use only one parameter at a time depending on the scope of
your mailbox report.
For more script details, a video demo, or to give feedback please go to:
To see the examples, type: "get-help C:\Scripts\demo\Get-MailboxReport.ps1 -examples".
For more information, type: "get-help C:\Scripts\demo\Get-MailboxReport.ps1 -detailed".
For technical information, type: "get-help C:\Scripts\demo\Get-MailboxReport.ps1 -full".
Depending on which parameter you use the output will vary.
- If you use the -mailbox parameter to query a single mailbox, then the output will appear in the console window. I don't really see the need to output a single mailbox's details to a CSV file.
- If you use any of the other parameters, -server, -database, -file, or -all, the output will be written to a CSV file in the same folder you're running the script from.
- You can use the optional -filename parameter to specify your own output file name
Once you've generated the CSV report you can open it with Excel and begin to analyze the data.