-
Notifications
You must be signed in to change notification settings - Fork 1
Agent Health
Emre Guclu edited this page Dec 3, 2020
·
1 revision
$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
}
}
Returns the unhealthy Health Service Watchers. You should check this daily
Get-SCOMClass -DisplayName "Health Service Watcher" | Get-SCOMClassInstance | where {$_.HealthState -eq 'Error'}
Footer notes Emre Güçlü emreg@microsoft.com
Side bar