Advertisement
Guest User

Untitled

a guest
Jun 16th, 2014
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Param(
  2.   [string]$HealthSet
  3. )
  4.  
  5. $hostname = "host.domain"
  6.  
  7. $status = 0
  8.  
  9. add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn
  10.  
  11.  
  12. # Get health checks for role
  13. $HealthSetResult = (get-servercomponentstate $hostname | Where-Object {$_.Component -eq $HealthSet})
  14.  
  15. # Filter by Degraded state
  16. $DegradedHealthChecks = $HealthSetResult | Where-Object {$_.State -eq "Inactive"}
  17.  
  18. if($DegradedHealthChecks.Length -gt 0) {
  19.  
  20.     # Atleast one health check is degraded or unhealthy
  21.  
  22.     $status=2
  23.  
  24.     $desc = $HealthSet
  25.  
  26.     $desc = "$desc in Degraded or Unhealthy State"
  27. }
  28.  
  29. if ($status -eq "2") {
  30.     Write-Host "CRITICAL: $desc"
  31. } elseif ($status -eq "0") {
  32.     Write-Host "OK: $HealthSet - $($HealthSetResult.Length) checks are OK"
  33. }
  34.  
  35. exit $status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement