PoshCode Logo PowerShell Code Repository

Get-MailboxesOverSizeLim by Chris Brown 10 months ago
View followups from romajan | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/2597"></script>download | new post

Emails a report of Exchange 2010 mailboxes over their size limit.
See here for post: http://www.flamingkeys.com/2011/04/exchange-2010-mailboxes-over-size-limit-report/

  1. # -------------------------------------------------------------------------------
  2. # Script: Get-MailboxesOverSizeLimit.ps1
  3. # Author: Chris Brown
  4. # Date: 04/04/2011 10:41:00
  5. # Keywords:
  6. # comments:
  7. #
  8. # Versioning
  9. # 04/04/2011  CJB  Initial Script
  10. #
  11. # -------------------------------------------------------------------------------
  12.  
  13. # &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824;
  14. #                           ~ ~ ~ Variables ~ ~ ~
  15. # ~~ Mail Server Details ~~
  16. $SmtpServer = "mailserver.yourdomain.local"
  17. $FromAddress = "alerts@yourdomain.com"
  18. $ToAddress = "HelpDesk@yourdomain.com"
  19. $Subject = "[Exchange] Mailboxes over size limits"
  20. #
  21. #
  22. # &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824; &#9829; &#9830; &#9827; &#9824;
  23.  
  24. if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null) {
  25.         Write-Verbose "Exchange 2010 snapin is not loaded. Loading it now."
  26.         try { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010; Write-Verbose "Loaded Exchange 2010 snapin" }
  27.         catch { Write-Error "Could not load Exchange 2010 snapins!"; }
  28. }
  29.  
  30. $overLimit = Get-Mailbox | Get-MailboxStatistics -WarningAction SilentlyContinue | Where {"ProhibitSend","MailboxDisabled" -contains $_.StorageLimitStatus}
  31.  
  32. if ($overLimit.Count -gt 0) {
  33.         $mailBody = $overLimit | ft DisplayName,TotalItemSize,StorageLimitStatus | Out-String
  34.         Send-MailMessage -Body $mailBody.ToString() -From $FromAddress -SmtpServer $SmtpServer -Subject $Subject -To $toAddress
  35. } else {
  36.         "No results"
  37. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me