Enabling specific SCOM monitors
This code demonstrates how to enable a specific monitor from a specific management pack. As we are aware, even after we import a new management pack with several monitors configured, it will not be effective until we enable the monitor. So, here is the sample code that will help you to enable the monitor through PowerShell.
Here, we will enable the TestClass.FileMonitor.TestMP.Monitor
monitor in the FileMonitor.TestMP.MP
management pack on the TestClass.FileMonitor.TestMP.CLS1
class:
$MP = Get-SCOMManagementPack -displayname "FileMonitor.TestMP.MP" | where {$_.Sealed -eq $False} $Class = Get-SCOMClass -DisplayName "TestClass.FileMonitor.TestMP.CLS1" $Monitor = Get-SCOMMonitor -DisplayName "TestClass.FileMonitor.TestMP.Monitor" Enable-SCOMMonitor -Class $Class -ManagementPack $MP -Monitor $Monitor