Auto Email Exchange 2007 Mailbox Report
Posted March 12th, 2009 by Matt ShadboltHi 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: Email from PowerShell, Email Report, Exchange 2007, Mailbox Size, PowerShell
One Response

One Response to “Auto Email Exchange 2007 Mailbox Report”
September 2nd, 2010 at 10:51 pm
This is what I was looking for.
I added “-Descending” and all is very nice.
Thanks.
Paul
Leave a Reply