Search This Blog

Friday 5 July 2013

Agent Health State Report with Powershell


As of 01/05/2017, this blog will not be updated or maintained

Everyone likes to know what the overall state of their SCOM agents are. You can see this info in the console, but where’s the fun in that? Here’s a PowerShell way to do it…

This script will produce a list of the total number of agents that are in these Health States:
Healthy (Success) , Warning , Critical (Error) or Uninitialized.
 
$healthy = $uninitialized = $warning = $critical =0
switch (Get-Agent | Select-Object HealthState) {
 {$_.HealthState -like “Success”} {$healthy++}
 {$_.HealthState -like “Warning”}  {$warning++}
 {$_.HealthState -like “Error”} {$critical++}
 {$_.HealthState -like “Uninitialized”} {$uninitialized++}
}
“Agents Healthy ……………… = $healthy”
“Agents Warning ……………… = $warning”
“Agents Critical……………… = $critical”
“Agents Uninitialized…………. = $uninitialized”
 
The output will look something like this…

Agents Healthy ……………… = 295
Agents Warning ……………… = 29
Agents Critical……………… = 14
Agents Uninitialized…………. = 1

Hope that this post was helpful.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.