Welcome to Matts Admin tips. This blog is full of little fixes, tutorials and work-arounds to those anoying problems that a Systems Administrator might face. If you find something that you have found useful please leave me a comment - I appreciate knowing that I've helped! Also, feel free to leave a comment if my tips or ideas don't work in your environment... I monitor them closely and would be happy to help! Matt

Auto Email Exchange 2007 Mailbox Report

Hi all. I’ve written this simple PowerShell script to output your user mailboxes, their total size and the item count – the script will then email the output to a specified account in a pretty HTML table format. Feel free to download the .ps1 file and run it as you wish.

Remember that you need to “Set-ExecutionPolicy RemoteSigned” in the Task Scheduler for the PS script to run correctly. Also, if you are going to run this PS script on a remote server you may need to add the MSExchange PS Snappin. To do this just add “Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin” to the first line of the script. You obviously need to change the mail server and recipient options.

Here’s the script download EmailMailboxSizeReport.ps1

And a break down of the script:

#Firstly, get the users mailbox… ONLY objects that are UserMailbox and not HiddenFromAddressListsEnabled
$MailboxUser = Get-Mailbox | Where {($_.RecipientType -eq “UserMailbox”) -and ($_.HiddenFromAddressListsEnabled -eq $False)}

#Secondly, get the mailbox statistics for the selected users. Some formatting also
$MessageBody = $MailboxUser | Get-MailboxStatistics | Sort-Object TotalItemSize | Select DisplayName, ItemCount, @{Expression={$_.TotalItemSize.Value.ToMB()};Name=”MailboxSize MB”} | ConvertTo-html

#Finally, enter your mail server details
$FromAddress = “FromAddress@YourDomain.com”
$ToAddress = “ToAddress@YourDomain.com”
$MessageSubject = “PowerShell Report Subject”
$SendingServer = “YourMailServerAddress”
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody
$SMTPMessage.IsBodyHtml = $true
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)

#Written by Matt Shadbolt
#http://www.mattlog.net

Tags: , , , ,

One Response
Filed under:Uncategorized

One Response to “Auto Email Exchange 2007 Mailbox Report”

Leave a Reply