Share via


OpsMgr 2012 - Tuning your Management Pack via PowerShell

I recently had to go through an exercise of tuning an Exchange 2010 Management Pack. Let's just say that with over 1000 rules it is not much fun… 

First things first - Go to your technology SME. They will tell you what they need to have monitored in their deployment. There are a lot of services that are typically disabled in a restricted deployment of Exchange. And that means a lot of disabling of rules and monitors

I used MPViewer (you can download it from here https://blogs.msdn.com/b/dmuscett/archive/2012/02/19/boris-s-tools-updated.aspx ) to extract the Exchange 2010 Management Pack into Excel format. I gave the 2000+ rules and monitors to the SME and wished him good luck!

 

A week later…. What I ended up with was something like this:

 

The SME highlighted red all the 100s of rules and monitors he wanted to have disabled… 

Why not just disable the discoveries, you say? Well, this management pack was written in a way that if I disabled the discovery rules, I would end up missing out on a lot of classes that I actually need… oh well… 

 

I had a task of creating overrides for them all… pay back is a ….

Okay not to worry… PowerShell is my friend…

 

I copied everything that I needed to override (hint: sort it by colour) into a new spreadsheet, and renamed the headings:

Target = class

Name = rule

 

I got rid of any quotes and replace with *, so posh wouldn’t get confused… and then saved it as a csv file…

 

I then used the following commands go through them all and disable them…

 Import-module operationsmanager
 
 $mp = Get-SCOMManagementPack -DisplayName "exchange server 2010 - Overrides"
 
 $list = import-csv C:\software\disable-exchange-rules.csv
 
 foreach ($item in $list)
 {
 
     write-host "getting Class $item.class...." -ForegroundColor Cyan
     write-host
 
     $class = Get-SCOMClass -DisplayName $item.class
 
     write-host "getting rule $item.rule ...." -ForegroundColor Magenta
     write-host
 
     $rule = get-scomrule -displayname $item.rule
 
     write-host "Disabling rule $rule.displayname" -ForegroundColor green
     write-host
 
     Disable-SCOMRule -Class $class -ManagementPack $MP -rule $rule
 
 }

 

I used a similar script for the monitors:

 

Import-module operationsmanager

$mp = Get-SCOMManagementPack -DisplayName "exchange server 2010 - Overrides"

$list = import-csv C:\software\disable-exchange-rules.csv

foreach ($item in $list)

   
write-host "getting Class $item.class...." -ForegroundColor Cyan   
write-host

   
$class = Get-SCOMClass -DisplayName $item.class

write-host "getting monitor $item.monitor ...." -ForegroundColor Magenta
write-host

$monitor = get-scommonitor -displayname $item.monitor

 
write-host "Disabling monitor $monitor.displayname" -ForegroundColor green 
write-host

    
Disable-SCOMRule -Class $class -ManagementPack $MP -monitor $monitor

}

 

Easy!!! There were also a few rules that were highlighted green, which needed to be enabled… I did
the same process, but instead of using the command Disable-SCOMRule, I used Enable-SCOMRule

Comments

  • Anonymous
    November 10, 2014
    Great posting! Thank you.
  • Anonymous
    November 20, 2014
    hey, I'd like to consult you on something but have not found your email address, could you contact me at fgdaishu@126.com? thank you.
  • Anonymous
    December 10, 2014
    Hi , this is nice as useful Script , however I am trying to change SevPriority of All the alert based on the Display Name , Can you let me know if this is possible using PowerShell.