Listing all unhealthy SCOM agents
The following code lists all the SCOM agents that are not healthy for various reasons. We can use this report as a reference for further troubleshooting:
$AllAgents = Get-SCOMAgent $UnHealthyAgents = $AllAgents | where {$_.HealthState -ne "Success"} | select Name,HealthState Write-Host "Unhealthy Agent list = `n $UnHealthyAgents"