February 24 2009

Email HTML report of largest Exchange 2007 mailboxes

This PowerShell script queries the defined Exchange 2007 server and emails in HTML format the top 25 biggest mailboxes to the defined receipents. Simply create a scheduled task and you can have a automated weekly report:


# Name: top25.ps1
# Purpose: Report on the 25 largest mailboxes on an Exchange server and email this report in HTML format

# Set the Exchange server to run the query against

$ExchangeServer = “EXCHANGESERVERNAME”

# Run the query

$Top25Users = Get-MailboxStatistics -server $ExchangeServer |sort-object -Property totalitemsize -des |select-object Displayname, ItemCount, @{name=’Total Item Size (MB)’;expression={$_.totalitemsize/1MB}} -first 25 |Convertto-html

# Set the mail message properties

$FromAddress = “FROM@DOMAIN.COM.AU”
$ToAddress = “TO@DOMAIN.COM.AU”
$MessageSubject = “Weekly report: Top 25 biggest mailboxes on Exchange server ” + $ExchangeServer
$SMTPServer = “SMTPSERVER.DOMAIN.COM.AU”

# Create the mail message

$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $Top25Users
$SMTPMessage.IsBodyHtml = $true

# Send the message

$SMTPClient = New-Object System.Net.Mail.SMTPClient $SMTPServer
$SMTPClient.Send($SMTPMessage)



----------------------------------------------------------------------------
I use a maximum of one Google Ad per post to help offset some of my blog hosting costs.

----------------------------------------------------------------------------


Tags: , , ,

Posted February 24, 2009 by danovich in category "Exchange", "Powershell

Leave a Reply