SCOM Monitor Reset Script | Quisitive
General Quisitive gradient background
SCOM Monitor Reset Script
May 15, 2014
Matthew Dowst
This script will allow you to reset a specified monitor on all systems by just passing the monitor’s name.
code_1060567244

This script was presented by Cameron Fuller and the meat of it was written John Curtiss. This script will allow you to reset a specified monitor on all systems by just passing the monitor’s name.

To execute the script, save it as a .ps1 and pass the parameters for monitor name and management server. If you don’t specify management server it will default to local host.

Syntax
monitor_reset.ps1 –ManagementServer <MP Name> –MonitorName <Monitor>

Example
monitor_reset.ps1 –ManagementServer SCOM01 –MonitorName ‘Windows Event Log Viewer’

Param(

   [string]$ManagementServer,

   [Parameter(Mandatory=$True)]

   [string]$MonitorName

)

# Set parameters

If(!($ManagementServer))

{$ManagementServer = "localhost"}

 

# Load OpsMgr Module

if(@(get-module | where-object {$_.Name -eq "OperationsManager"}  ).count -eq 0)

        {Import-Module OperationsManager -ErrorVariable err -Force}

 

# Execute script

New-SCOMManagementGroupConnection -ComputerName $ManagementServer

$Monitors=Get-SCOMMonitor -ComputerName $ManagementServer | where {$_.DisplayName -eq $MonitorName}

foreach ($Monitor in $Monitors) {

     get-scomclass -name $Monitor.target.identifier.path |

     Get-SCOMClassInstance | where {$_.HealthState.value__ -gt 1} |

     foreach {$_.ResetMonitoringState($Monitor)}

}