How to Query for All Rules That Have a Noncategory Override

Updated: January 31, 2012

Applies To: System Center 2012 - Operations Manager

You can query for rules that have a noncategory override by defining criteria in the class constructor. The criteria syntax is defined in Criteria Expression Syntax.

The following code example queries for all the rules that have a noncategory override:

/// <summary> 
/// Query for rules that have a non-category override.
/// </summary>
using System;
using System.Collections.Generic;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;

namespace SDKSamples
	class Program
		static void Main(string[] args)
			ManagementGroup mg = new ManagementGroup("localhost");

			// The criteria specifies that you want to collect
			// all the rules that have a non-category override.
			ManagementPackRuleCriteria ruleCriteria =
				new ManagementPackRuleCriteria(
				"HasNonCategoryOverride = 1");

			Console.WriteLine("Querying for data...");
			IList<ManagementPackRule> monitoringRules =

			// Display information about each rule.
			foreach (ManagementPackRule rule in monitoringRules)
				Console.WriteLine("Rule name: " + rule.Name);
				Console.WriteLine("Category: " + rule.Category);
				Console.WriteLine("Enabled: " + rule.Enabled.ToString());
				Console.WriteLine("Has non-category override: " + rule.HasNonCategoryOverride);
				Console.WriteLine("Description: " + rule.Description +

See Also