Skip to content

Agent Health

Emre Guclu edited this page Dec 3, 2020 · 1 revision

List Computers those are not reachable

$MonitorColl = @()
$MonitorColl = New-Object "System.Collections.Generic.List[Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitor]"

$objects = get-scomclass -DisplayName "Health Service Watcher" | Get-SCOMClassInstance
$monitor = Get-SCOMMonitor -DisplayName 'Computer Not Reachable'

ForEach ($object in $objects)
{
    #Set the monitor collection to empty and create the collection to contain monitors
    $MonitorColl = @()
    $MonitorColl = New-Object "System.Collections.Generic.List[Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitor]"

    #Get specific monitors matching a displayname for this instance of URLtest ONLY
    #$Monitor = Get-SCOMMonitor -Instance $object -Recurse| where {$_.DisplayName -eq "Computer Not Reachable"} 
    
    #Add this monitor to a collection
    $MonitorColl.Add($Monitor)

    #Get the state associated with this specific monitor
    $State=$object.getmonitoringstates($MonitorColl)

if ($state.HealthState -eq 'Error') {  
$Props=@{}
$Props.ServerName=$Object.DisplayName
$Props.Reachable=$state.HealthState
New-Object -TypeName PSCustomObject -Property $props | Write-Output 
}
}

Unhealthy Watchers.

Returns the unhealthy Health Service Watchers. You should check this daily

 
Get-SCOMClass -DisplayName "Health Service Watcher" | Get-SCOMClassInstance | where {$_.HealthState -eq 'Error'}
 

Side bar

Clone this wiki locally