Disabling all Rules in a SCOM 2012/2016 Management Pack

So last night I was on a call with a customer and during that conversation the question was asked, ‘Can we disable all rules in a management pack using PowerShell or the Console?’.

Well yes you can, although it’s a pretty drastic measure to disable everything…That said the task itself is pretty easy. Well, actually it’s pretty long winded if you use the console but yes it can be done…1 by 1, by 1, by 1… sigh. Be prepared to stay awhile if you use this method.

PowerShell is the way…let’s see how.

If you’re planning on disabling rules then you’ll need to override them, essentially changing them to enabled=false… So I’ll assume you have a sealed MP…let’s say it’s the SQL Server 2012 one…and you want to turn off all rules. So we’ll use the “Microsoft.SQLServer.2012.Monitoring” Management Pack.

Step 1…Create a blank unsealed MP to store the overrides in. You can do this in the console, or if you’re game…Google how to do this in PowerShell as well. Once you’ve created your Overrides MP, just note down the name.

microsoft-sqlserver-monitoring-overrides

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 2…Change lines 1 and 2 to the names of the MP you wish to disable the rules in and the overrides MP you wish to save the overrides to.

Step 3…Run the script!

 

# Disable all Rules in a Sealed MP to an Unsealed Overrides MP

$mp = Get-SCOMManagementPack | ? {$_.Name -eq “Microsoft.SQLServer.2012.Monitoring“}
$overridesmp = Get-SCOMManagementPack | ? {$_.Name -eq “Microsoft.SQLServer.Monitoring.Overrides“}
$Rules = Get-SCOMRule -ManagementPack $mp
Disable-SCOMRule -Rule $Rules -ManagementPack $overridesmp

 

Depending on the number of Rules in this Management Pack you can expect this to take a few minutes…

And that’s it! When you open the Overrides MP you’ll see plenty of overrides in there, and all rules will be turned off…all done scriptomatically of course!

Oh and if it isn’t plainly obvious from that code…you can ‘enable’ all Rules by changing the last line to “Enable-SCOMRule”.

 

 
Comments

Life saver! thanks Tim

Leave a Reply