AgentManagedComputer Class

Updated: April 16, 2012

Represents a managed computer to which an agent has been deployed. Namespace: Microsoft.EnterpriseManagement.Administration
Assembly: Microsoft.EnterpriseManagement.OperationsManager (in Microsoft.EnterpriseManagement.OperationsManager.dll)Dim instance As AgentManagedComputer <SerializableAttribute> _ Public Class AgentManagedComputer Inherits ComputerHealthService[SerializableAttribute] public class AgentManagedComputer : ComputerHealthService[SerializableAttribute] public ref class AgentManagedComputer : public ComputerHealthService/** @attribute SerializableAttribute() */ public class AgentManagedComputer extends ComputerHealthServiceSerializableAttribute public class AgentManagedComputer extends ComputerHealthService

The following example shows how to obtain information about an agent-managed computer. In this example, mg is a ManagementGroup instance and agentFqdn is the fully qualified domain name of the agent-managed computer from which you want to obtain information.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;


namespace SDKSamples
{
	class Program
	{
		const string agentFqdn = "AgentFullyQualifiedDomainName";
			 
		static void Main(string[] args)
		{
			try
			{
				ManagementGroup mg = new ManagementGroup("localhost"); 	
				AgentManagedComputerCriteria agentCriteria = new AgentManagedComputerCriteria("Name = '" + agentFqdn + "'");

				//Get the agent-managed computer with the specified FQDN.
				IList<AgentManagedComputer> agents = mg.Administration.GetAgentManagedComputers(agentCriteria);


				//Make sure one computer is returned
				if (agents.Count > 1 || agents.Count < 1)
				{
					throw new Exception("Expected one computer with the given FQDN");
			}

				//Display the name of the computer, its primary management server
				//and any failover servers.
				foreach (AgentManagedComputer agent in agents)
				{
					Console.WriteLine("Computer name: " + agent.ComputerName);
					Console.WriteLine("Primary management server: " + agent.PrimaryManagementServerName);
					Console.WriteLine("Failover servers: ");
					ReadOnlyCollection<ManagementServer> servers = agent.GetFailoverManagementServers();
					if (servers.Count > 0)
					{
						foreach (ManagementServer server in servers)
						{
							Console.WriteLine(server.PrincipalName);
					}
				}
					else
					{
						Console.WriteLine("No failover servers assigned.");
				}
			}
		}
			catch (Exception e)
			{
				Console.WriteLine("Could not display agent information. " + e.Message);
		}
	}
}
}

You can get a collection of the agent-managed computers in a Management Group by using GetAgentManagedComputers.

You can get a collection of agent-managed computers that are managed by a specific server by using GetAgentManagedComputers.



  
    
      Microsoft.EnterpriseManagement.Administration.AgentManagedComputer
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows Server 2003, and

Target Platforms