PoshCode Archive  Artifact [f2a952573e]

Artifact f2a952573e8898e570691ea78173c7e4063179e4b00cd38b5c14c0b7d5e552d5:

  • File Get-MailboxesOverSizeLim.ps1 — part of check-in [305335b131] at 2018-06-10 13:18:05 on branch trunk — Emails a report of Exchange 2010 mailboxes over their size limit. (user: Chris Brown size: 2510)

# 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: 2979
# x-archived: 2012-01-14T07:05:44
# x-published: 2012-09-29T14:14: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 -ResultSize unlimited| 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"
}