Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param(
- [string]$HealthSet
- )
- $hostname = "host.domain"
- $status = 0
- add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn
- # Get health checks for role
- $HealthSetResult = (get-servercomponentstate $hostname | Where-Object {$_.Component -eq $HealthSet})
- # Filter by Degraded state
- $DegradedHealthChecks = $HealthSetResult | Where-Object {$_.State -eq "Inactive"}
- if($DegradedHealthChecks.Length -gt 0) {
- # Atleast one health check is degraded or unhealthy
- $status=2
- $desc = $HealthSet
- $desc = "$desc in Degraded or Unhealthy State"
- }
- if ($status -eq "2") {
- Write-Host "CRITICAL: $desc"
- } elseif ($status -eq "0") {
- Write-Host "OK: $HealthSet - $($HealthSetResult.Length) checks are OK"
- }
- exit $status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement