$server = "" $sess = New-PSSession -ConnectionURI "http://$server/PowerShell" -ConfigurationName Microsoft.Exchange -Authentication Kerberos Import-PSSession $sess $unhealthy_sets = Get-HealthReport -Identity $server | Where-Object {$_.AlertValue -eq "Unhealthy"} if ($unhealthy_sets.Count -gt 0) { # all significant info is found, of all places, in the event logs # this will usually take forever # for practical application, define dynamic XPath filters and apply those, *especially* if doing this remotely $events = Get-WinEvent -ComputerName $server -LogName Microsoft-Exchange-ActiveMonitoring/MonitorDefinition | Foreach-Object { ([xml]($_.ToXML())).Event.UserData.EventXML } # we actually don't need probe definitions at this stage #$probes = Get-WinEvent -ComputerName $server -LogName Microsoft-Exchange-ActiveMonitoring/ProbeDefinition | Foreach-Object { ([xml]($_.ToXML())).Event.UserData.EventXML } $results = Get-WinEvent -ComputerName $server -LogName Microsoft-Exchange-ActiveMonitoring/ProbeResult | Foreach-Object { ([xml]($_.ToXML())).Event.UserData.EventXML } foreach ($uhs in $unhealthy_sets) { Write-Host "Unhealthy set: $($uhs.HealthSet)" $unhealthy_monitors = Get-ServerHealth -Identity $server -HealthSet $uhs.HealthSet | Where-Object {$_.AlertValue -eq "Unhealthy"} foreach ($uhm in $unhealthy_monitors) { Write-Host "- Unhealthy monitor: $($uhm.Name) for target $($uhm.TargetResource)" $uhprobes = $events.Where({$_.Name -like "*$($uhm.Name)*"}) | Select -ExpandProperty SampleMask -Unique foreach ($uhp in $uhprobes) { $results.Where({$_.ResultName -like $uhp}) | select Error } } } } Remove-PSSession $sess