Exchange 2010 Mailbox Report Script

One of the tasks that every Exchange Server administrator faces as part of their daily or weekly maintenance is getting the mailbox size report of the Exchange Server. The PowerShell commands do help in getting the relevant data, but doing this rudementary task manually everytime is painstaking. Here is a small exchange 2010 mailbox report script which can used to generate the mailbox statistics report and then automatically email the same as an attachment. To automate this further, one can create a Scheduled Task in Task Manager so that it runs at the specified interval.

###Exchange Mailbox Statistics Script
###Modify Variable Data
$FromAddress = "noreply@domain.com"
$ToAddress = "administrator@domain.com"
$MessageSubject = "Exchange Mailbox Report"
$MessageBody = "Mailbox Statistics of Exchange Server is attached with this email."
$SendingServer = "exchangeserver.yourdomain.com"
####DO NOT EDIT BELOW THIS LINE
###Get Stats and Prepare Text File
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}}, ItemCount, StorageLimitStatus > mailboxes.txt
###Create Email and Attach Report
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, 
$MessageSubject, $MessageBody
$Attachment = New-Object Net.Mail.Attachment("mailboxes.txt")
$SMTPMessage.Attachments.Add($Attachment)
###Send Email
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)

Hope the above script helps and saves the administration time.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

You May Also Like