How to Get a Single Instance
Updated: April 25, 2012
Applies To: System Center 2012 - Service Manager
Each enterprise management object (EMO) has an identifier, represented by the Id property. This property value is a GUID that uniquely identifies the object. The EnterpriseManagementGroup class that is used to connect to the server, has a property named EntityObjects that provides access to enterprise management objects. To get a specific EMO, call the GetObject method, passing in the GUID of the EMO you want to obtain. If the GUID does not match any known identifier, the ObjectNotFoundException exception will be raised.
To get an instance of an enterprise management object by identifier
Connect to the server by using the EnterpriseManagementGroup class.
Call the GetObject method on the EntityObjects property. Provide the GUID that matches the EMO you want to obtain.
Example
The following example establishes a connection to a locally hosted server and gets an EnterpriseManagementObject instance by GUID:
EnterpriseManagementGroup mg = new EnterpriseManagementGroup("localhost"); // Get an object by GUID EnterpriseManagementObject existingRequest = mg.EntityObjects.GetObject<EnterpriseManagementObject>(new Guid("ec14c9b3-22c5-8bbb-9e4e-a74a124dc3e5"), ObjectQueryOptions.Default);
Compiling the Code
Namespaces
System |
Microsoft.EnterpriseManagement |
Microsoft.EnterpriseManagement.Common |
Assemblies
mscorlib |
Microsoft.EnterpriseManagement.Core |