OpsMgr 2012: Disabling Rules and Monitors in Bulk in PowerShell

Blog, Operations Manager, Powershell

As with several other areas of the Operations Manager Command Shell, disabling (or enabling) rules and monitors in bulk is quite easy, and the Operations Console UI provides a way to quickly validate your results after the fact.

Six cmdlets you will need when working with overrides on rules and monitors are:

  • Get-SCOMMonitor – retrieves monitors based on -displayname or other search filters you apply
  • Get-SCOMRule – retrieves monitors based on -displayname or other search filters you apply
  • Enable-SCOMRule – Enables the rule or rules that match your search criteria.
  • Enable-SCOMMonitor – Enables the monitor or monitors that match your search criteria.
  • Disable-SCOMRule – Disables the rule or rules that match your search criteria.
  • Disable-SCOMMonitor – Disables the monitor or monitors that match your search criteria.

Let’s take a quick look at these cmdlets in action to better understand how they work and how you can verify the results of your scripts.

Disabling Rules in Bulk (sample script)

To disable rules in bulk (that target SQL DB Engine and contain “*events/sec*” in their name, you’ll need a script that performs the following steps:

  • Retrieve the management pack in which to store the overrides
  • Retrieve the class that will be targeted by the override
  • Retrieve the rules or monitors that will be disabled
  • Disable the rule or monitor

Here is the sample that disables all rules matching the “*events/sec*” filter.

NOTE: You may have already guessed that you’ll need to carefully check which rules are returned by the Get-SCOMRule line and what class they target to ensure you retrieve the correct class with Get-SCOMClass. Just to be safe, you could actually find the target of the rule using Get-SCOMRule and pass that to Get-SCOMClass.

Checking Your Work

You can view your results in the Operations Console in the Authoring space in the Overrides node.

image

 

Re-enabling Disabled Rules (sample script)

To re-enable the same rules, you can use the Enable-SCOMRule cmdlet

Checking Your Work

Again, you can view your results in the Operations Console in the Authoring space in the Overrides node.

image

Additional Resources

You’ll find a growing number of System Center, Cloud and PowerShell resources here on SCC in the “Master Collection of System Center PowerShell” and elsewhere. A few related Operations Manager 2012 Command Shell articles

OpsMgr 2012: Group Maintenance Mode via PowerShell (the way it should be)

OpsMgr 2012: Running a Task in Bulk Using PowerShell

OpsMgr 2012: Automating Agent Discovery and Deployment with PowerShell [sample script]

OpsMgr 2012: Identifying Computers in Active Directory without an OpsMgr Agent Installed [sample script]

OpsMgr 2012 Quick Tip: Finding servers experiencing the most heartbeat failures with PowerShell

 

Reference Link – http://www.systemcentercentral.com/opsmgr-2012-disabling-rules-and-monitors-in-bulk-in-powershell/

Posted By Sheikvara

+919840688822, +919003270444

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s