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.
1
2
3
4
5
|
$MP = Get-SCOMManagementPack -displayname “SQL Server 2008 Overrides” | `
where {$_.Sealed -eq $False}
$Class = Get-SCOMClass -DisplayName “SQL DB Engine”
$Rule = Get-SCOMRule -DisplayName “*Events/sec”
Disable-SCOMRule -Class $Class -Rule $Rule -ManagementPack $MP -Enforce
|
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.
Re-enabling Disabled Rules (sample script)
To re-enable the same rules, you can use the Enable-SCOMRule cmdlet
1
2
3
4
5
|
$MP = Get–SCOMManagementPack –displayname “SQL Server 2008 Overrides” | `
where {$_.Sealed –eq $False}
$Class = Get–SCOMClass –DisplayName “SQL DB Engine”
$Rule = Get–SCOMRule –DisplayName “*Events/sec”
Enable–SCOMRule –Class $Class –Rule $Rule –ManagementPack $MP –Enforce
|
Checking Your Work
Again, you can view your results in the Operations Console in the Authoring space in the Overrides node.
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 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
Hello there! This is my 1st comment here so I just wanted to give a quick shout out and tell you I really enjoy reading through your articles. Can you suggest any other blogs/websites/forums that cover the same topics? Appreciate it!
LikeLiked by 1 person