You can query for computers running Windows Server 2003 or for other instances of a Management Object by first querying for the Management Class that defines the type of the instances. After the type is retrieved, you can then query for the instances by using the GetPartialMonitoringObjects method or the GetMonitoringObjects method. The following example queries for all the instances of computers running Windows Server 2003.

C#  Copy Code
/// <summary> 
/// Query for all computers running Windows Server 2003 in the management group.
/// </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
			// computers running Windows Server 2003.
			MonitoringClassCriteria classCriteria = 
				new MonitoringClassCriteria("Name = 'Microsoft.Windows.Server.2003.Computer'");
			Console.WriteLine("Querying for data...");
			// There should only be one item in the monitoringClasses collection.
			ReadOnlyCollection<MonitoringClass> monitoringClasses = 
			// Get all instances of computers running Windows Server 2003 in the management group.
			ReadOnlyCollection<PartialMonitoringObject> monitoringObjects =

			// Display information about each computer running Windows Server 2003.
			foreach (PartialMonitoringObject monitoringObject in monitoringObjects)
				Console.WriteLine("Server name: " + monitoringObject.Name);
				Console.WriteLine("Last modified: " + monitoringObject.LastModified +

Send comments about this topic to Microsoft.