# encoding: ascii
# api: powershell
# title: Get-MailboxesOverSizeLim
# description: Emails a report of Exchange 2010 mailboxes over their size limit.
# version: 0.1
# type: script
# author: Chris Brown
# license: CC0
# x-poshcode-id: 2597
# x-archived: 2012-01-27T17:45:48
# x-published: 2012-04-03T18:47:00
#
# See here for post: http://www.flamingkeys.com/2011/04/exchange-2010-mailboxes-over-size-limit-report/
#
# -------------------------------------------------------------------------------
# Script: Get-MailboxesOverSizeLimit.ps1
# Author: Chris Brown
# Date: 04/04/2011 10:41:00
# Keywords:
# comments:
#
# Versioning
# 04/04/2011 CJB Initial Script
#
# -------------------------------------------------------------------------------
# ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠
# ~ ~ ~ Variables ~ ~ ~
# ~~ Mail Server Details ~~
$SmtpServer = "mailserver.yourdomain.local"
$FromAddress = "alerts@yourdomain.com"
$ToAddress = "HelpDesk@yourdomain.com"
$Subject = "[Exchange] Mailboxes over size limits"
#
#
# ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠ ♥ ♦ ♣ ♠
if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null) {
Write-Verbose "Exchange 2010 snapin is not loaded. Loading it now."
try { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010; Write-Verbose "Loaded Exchange 2010 snapin" }
catch { Write-Error "Could not load Exchange 2010 snapins!"; }
}
$overLimit = Get-Mailbox | Get-MailboxStatistics -WarningAction SilentlyContinue | Where {"ProhibitSend","MailboxDisabled" -contains $_.StorageLimitStatus}
if ($overLimit.Count -gt 0) {
$mailBody = $overLimit | ft DisplayName,TotalItemSize,StorageLimitStatus | Out-String
Send-MailMessage -Body $mailBody.ToString() -From $FromAddress -SmtpServer $SmtpServer -Subject $Subject -To $toAddress
} else {
"No results"
}