As part of our customer tuning process we tend to pre-tune management packs by providing the customer with a spreadsheet with all rules & monitors. We work though this to decide what should be enabled or disabled when the management pack is imported into Operations Manager. From this spreadsheet we create a CSV file that is then used along with PowerShell to bulk enable or disable rules or monitors.
To get the spreadsheet it is possible to use the MPVeiwer tool created by Daniele Muscetta, which can be downloaded here: https://blogs.msdn.microsoft.com/dmuscett/2012/02/19/boriss-opsmgr-tools-updated/. This allows a sealed management pack to be output into a spreadsheet. The two columns of interest are Name & Target. Name being the name of the rule or monitor, and Target being the class.
I added an extra column called “Change?” so i could mark the objects to be enabled or disabled.
The next step is to create a CSV file with two columns called either Monitor & Class, or Rule & Class. Then you can copy the name and target columns for the rules or monitors to change, from the management pack spreadsheet directly to the CSV file.
Next on an Operations Manager Management Server open a PowerShell ISE window. The following 4 scripts can be run to either enable or disable rules & monitors:
Disable Rules:
Import-module operationsmanager
$mp = Get-SCOMManagementPack -DisplayName “<Override Management Pack Name>”
$list = import-csv “<CSV File Path>”
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
}
Enable rules:
Import-module operationsmanager
$mp = Get-SCOMManagementPack -DisplayName “<Override Management Pack Name>”
$list = import-csv “<CSV File Path>”
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 “Enabling rule $rule.displayname” -ForegroundColor green
write-host
Enable-SCOMRule -Class $class -ManagementPack $MP -rule $rule
}
Disable Monitors:
Import-module operationsmanager
$mp = Get-SCOMManagementPack -DisplayName “<Override Management Pack Name>”
$list = import-csv “<CSV File Path>”
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-SCOMMonitor -Class $class -ManagementPack $MP -monitor $monitor
}
Enable Monitors:
Import-module operationsmanager
$mp = Get-SCOMManagementPack -DisplayName “<Override Management Pack Name>”
$list = import-csv “<CSV File Path>”
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 “Enabling monitor $monitor.displayname” -ForegroundColor green
write-host
Enable-SCOMMonitor -Class $class -ManagementPack $MP -monitor $monitor
}
On running the script I get the following error:
Disable-SCOMRule : Cannot validate argument on parameter ‘Class’. The argument is null or empty. Provide an argument that is not
null or empty, and then try the command again.
At line:15 char:25
+ Disable-SCOMRule -Class $Class -ManagementPack $MP -rule $rule
+ ~~~~~~
+ CategoryInfo : InvalidData: (:) [Disable-SCOMRule], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.SystemCenter.OperationsManagerV10.Commands.DisableSCMonitor
ingRuleCommand
Any ideas where the problem is?
Yeah, you did zero self research