Here is a health check report script for your Exchange 2010/2013 email server:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
$smtpServer = "smtp.yourdomain.net" $smtpFrom = "reports@yourdomain.net" $smtpTo = "you@yourdomain.net,boss@yourdomain.net" $messageSubject = "Daily Exchange Health Report" $css = @" <style type="text/css"> h2 { font-family: verdana,arial,sans-serif; font-size:12px; color:#333333; } table { font-family: verdana,arial,sans-serif; font-size:11px; color:#333333; border-width: 1px; border-color: #666666; border-collapse: collapse; } table th { border-width: 1px; padding: 4px; border-style: solid; border-color: #666666; background-color: #dedede; } table td { border-width: 1px; padding: 4px; border-style: solid; border-color: #666666; background-color: #ffffff; } </style> "@ $messageBody = "" $connected = $false $remoteexchange = $false Try { . 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1' $remoteexchange = $true } Catch{ $messageBody += "Error running RemoteExchange.ps1: " + $error[0] } if ($remoteexchange) { try { Connect-ExchangeServer -auto $connected = $true } catch { $messageBody += "Connect-ExchangeServer -auto failed: " + $error[0] } if ($connected) { $MailboxSizes = Get-MailboxDatabase | Get-MailboxStatistics | where {$_.TotalItemSize -ge 2147400000} | Sort TotalItemSize -Descending| Select displayname,totalitemsize,ItemCount,StorageLimitStatus,ServerName,DatabaseName,LastLogonTime $MailboxBackupStatus = Get-MailboxDatabase -Status | Sort LastFullBackup | Select name,lastfullbackup,BackupInProgress,DatabaseSize,AvailableNewMailboxSpace $MailboxDatabaseHealth = Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus | Sort LogCopyQueueIncreasing,LogReplayQueueIncreasing,Status,MailboxServer | Select Status,MailboxServer,DatabaseName,CopyQueueLength,ReplayQueueLength,LogCopyQueueIncreasing,LogReplayQueueIncreasing $messageBody = "" $messageBody += "<h2>Exchange Backup Status</h2>" $messageBody += $MailboxBackupStatus | ConvertTo-Html -Fragment $messageBody += "<br><h2>Exchange Database Copy Health</h2>" $messageBody += $MailboxDatabaseHealth | ConvertTo-Html -Fragment $messageBody += "<br><h2>Exchange Top Mailbox Sizes</h2>" $messageBody += $MailboxSizes | ConvertTo-Html -Fragment } } $message = new-object System.Net.Mail.MailMessage $message.From = $smtpFrom $message.To.Add($smtpTo) $message.IsBodyHtml = $True $message.Subject = $messageSubject $message.body = ConvertTo-Html -Head "$css" -Body "$messageBody" # Uncomment below to output report to a html file # $message.body | set-content report.html $smtp = New-Object Net.Mail.SmtpClient($smtpServer) $smtp.Send($message) |
This needs to be run from a computer that has the Exchange admin tools installed or ideally from an Exchange server.
You can use this command to schedule it in Task Scheduler:
1 |
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -NonInteractive -WindowStyle Hidden -file "C:\Scripts\MailboxReportEmail.ps1" |