locked
SCOM 2012 Monitor Health State Reset script won't reset Agentless Cluster Resource RRS feed

  • Question

  • Found a script online to reset monitor health state in SCOM 2012. The script works fine on agent managed computer but not on agentless managed like virtual cluster resource. Script below. Does anyone know why script doesn't work on agentless managed like virtual cluster? Thanks

    Import-Module -Name "OperationsManager"
    New-SCManagementGroupConnection -ComputerName scomms01.enhnet.org

    #Based on the display name in object health explorer, get the monitor identity

    $monitors = get-scommonitor | where {$_.displayName -eq '*processing backlogged Events*' -OR '*print spooler*' -OR '*Average Wait Time*' -OR '*Microsoft Audit Collection*' -OR '*Cluster Disk*'}

    ForEach ($Monitor in $Monitors)
    {
        #Get the class the monitor applies to
        $MonitorClass = Get-SCOMClass -Id $Monitor.Target.Id

        $ActiveMonitors = Get-SCOMClassInstance -Class $MonitorClass | where{($_.healthstate -eq ‘Error’) -OR            ($_.healthstate -eq ‘Warming’) -AND
        ($_.IsAvailable -eq $true)}
       
        "Found '" + $ActiveMonitors.Count + "' active monitors."

        If ($ActiveMonitors -ne $null)
        {
            #loop through the list of degraded agents and perform actions described within the loop
            Foreach ($ActiveMonitor in $ActiveMonitors)
            {            
                #Output current entity working on and monitor being worked on.
                 "Resetting Health State on '" + $ActiveMonitor.FullName + "'"
                #Reset the monitor (assume that the monitor can't be recalculated since that is easier to code)
                 $ActiveMonitor.ResetMonitoringState($Monitor)
            }
        }

    }

    exit



    • Edited by Kel Ojes Wednesday, June 25, 2014 7:18 PM
    Wednesday, June 25, 2014 7:17 PM