How to Create or Remove a Connector by Using the Operations Manager Class Libraries

Updated: January 31, 2012

Applies To: System Center 2012 - Operations Manager

You can use the Operations Manager class libraries to create a connector that makes it possible for Operations Manager to communicate with an external system. If the external system runs on a Windows-based computer, using the class libraries is the preferred method for creating the connector.

Example

The following example demonstrates how to create a connector and how to remove a connector by using the Operations Manager class libraries:

/// <summary>
/// Creates a new connector by using the Operations Manager 
/// class libraries.
/// </summary>
using System;
using System.Collections.ObjectModel;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.ConnectorFramework;
using System.IO;
using System.Text;
using System.Xml;

namespace SDKSamples
{
	class Program
	{
		static void Main(string[] args)
		{
			ManagementGroup mg = new ManagementGroup("localhost");
			IConnectorFrameworkManagement icfm = mg.ConnectorFramework;

			MonitoringConnector connector = null;
			Guid connectorId = Guid.NewGuid();

			// Create a new connector.
			ConnectorInfo myConnectorInfo = new ConnectorInfo();
			myConnectorInfo.Name = "myConnector";
			myConnectorInfo.DisplayName = "My Connector";
			myConnectorInfo.Description =
				"This connector was created using the Operations Manager class libraries.";
			connector = icfm.Setup(myConnectorInfo, connectorId);
			connector.Initialize();
			Console.WriteLine("Created " + connector.Name + " with ID: " + connector.Id);


			// Remove the connector when finished with it.
			Console.WriteLine("Removing " + connector.Name);
			connector.Uninitialize();
			icfm.Cleanup(connector);
			Console.WriteLine("Connector removed.");
	}
}
}

See Also