In Operations Manager 2007, you can run predefined tasks that are included in your imported Management Packs, or you can create your own tasks. You can have a batch file or script run as a task remotely or locally. You can query for tasks by defining criteria in the Microsoft.EnterpriseManagement.Configuration.MonitoringTaskCriteria class constructor. The criteria syntax is defined in Criteria Expression Syntax. The following property names are valid names that can be used in the criteria expression:

The following code queries for the maintenance tasks that have SystemCenter in their name.

C#  Copy Code
/// <summary> 
/// Query for tasks.
/// </summary>
using System;
using System.Collections.ObjectModel;
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 maintenance tasks that have SystemCenter in their name.
			MonitoringTaskCriteria taskCriteria =
				new MonitoringTaskCriteria(
				"Category = 'Maintenance' AND Name LIKE '%SystemCenter%'");

			Console.WriteLine("Querying for data...");
			ReadOnlyCollection<MonitoringTask> tasks =

			// Display information about each task.
			foreach (MonitoringTask task in tasks)
				Console.WriteLine("Task name: " + task.Name);
				Console.WriteLine("Status: " + task.Status.ToString());
				Console.WriteLine("Category: " + task.Category);
				Console.WriteLine("Description: " + task.Description +

Send comments about this topic to Microsoft.
[an error occurred while processing this directive]