He had a few scripts he uses for monitoring, 2 he mentions I use as well but the third caught my eye.
It was a great oneliner (gotta love those) about the builtin HealthReport checks for Exchange.
The thing is that it was for 1 server and I have several so I made some adjustments and look here now it can be used for an array of servers.
Thanks Joakim, and check out his post about the Health Checking / Monitoring Exchange Server 2013/2016
Run it as a scheduled task daily with these arguments:
powershell.exe -noprofile - file "C:\_Scripts\Get-HealthReport\Get-HealthReport.ps1"
Note the spaces around "Style" for the table, I had some trouble getting the code to display correctly.
The Script:
############################################################################## ## Get-HealthReport ## Purpose: Sends report on the builtin Exchange HealthReport commandlets ## Author: Edwin van Brenk ## Date: 30 march 2017 ## Version: 1.0 ## Credits go to Joakim Storrank for his excellent oneliner:
## https://sysadminblogger.wordpress.com/2017/03/13/health-checking-monitoring-exchange-server-20132016/ ############################################################################## #Load Exchange 2013 Module Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn #SMTP options for sending the report email $smtpServer = "smtp.domain.com" $smtpFrom = "Get-HealthReport@domain.com" $smtpTo = "username@domain.com" $messageSubject = "Get-HealthReport $Computers" $logPath = "C:\_Scripts\Get-HealthReport\" # Build table for html files, remove the space around "Style" $style = "< style >BODY{font-family: Arial; font-size: 10pt;}" $style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}" $style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }" $style = $style + "TD{border: 1px solid black; padding: 5px; }" $style = $style + "</ style >" # End HTML Output file style $Date = Get-Date -Format dd-MM-yyyy ## The Servers to test $Computers = "server1","server2","server3","server4" # Start the Script Foreach($computer in $Computers) { # Choose what you want to see, all status' or everything but healthy or everything but healthy and disabled by commenting out the desired line #$GetStuff = Get-HealthReport -Server $Computer | Select server,state,healthset,alertvalue,lasttransitiontime,monitorcount #-AutoSize #$GetStuff = Get-HealthReport -Server $Computer | where {$_.alertvalue -ne “Healthy” -and $_.AlertValue -ne “Disabled”} | Select server,state,healthset,alertvalue,lasttransitiontime,monitorcount #-AutoSize $GetStuff = Get-HealthReport -Server $Computer | where {$_.alertvalue -ne “Healthy”} | Select server,state,healthset,alertvalue,lasttransitiontime,monitorcount #-AutoSize $GetStuff | ConvertTo-Html -head $style -body "Get-HealthReport from $Computer" | Out-File "$logPath\$Computer-$Date.html" } # Remove previously created combined.html Remove-Item $logPath\combined.html #Combine all the html files in to one file Get-Content -path $logPath\*.html | Add-Content -Path $logPath\combined.html #Send email message Send-Mailmessage -To $smtpto -From $smtpfrom -SmtpServer $smtpserver -Subject $messagesubject -Body (Get-Content $logpath\combined.html | Out-String) -BodyasHtml # Remove all html files to prevent filling the disk Remove-Item $logpath\*.html