An agent is an Operations Manager service that runs on each computer that you want to monitor. An agent captures information from the computer on which it is running, applies predefined rules to the captured data, and performs actions as defined by the rules. You can query for agents by defining criteria in the Microsoft.EnterpriseManagement.Administration.AgentManagedComputerCriteria 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 all the agents that were modified after 10/25/2006.

C#  Copy Code
/// <summary> 
/// Query for agents.
/// </summary>
using System;
using System.Collections.ObjectModel;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;
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
			// agents that were modified after 10/25/2006.
			AgentManagedComputerCriteria agentCriteria =
				new AgentManagedComputerCriteria(
				"LastModified >= '" +
				new DateTime(2006, 10, 25).ToString("G") + "'");

			ManagementGroupAdministration administration =

			Console.WriteLine("Querying for data...");
			ReadOnlyCollection<AgentManagedComputer> agents =

			// Display information about each agent.
			foreach (AgentManagedComputer agent in agents)
				Console.WriteLine("Agent name: " + agent.Name);
				Console.WriteLine("IPAddress: " + agent.IPAddress);
				Console.WriteLine("Health State: " + agent.HealthState);
				Console.WriteLine("Version: " + agent.Version +

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