You can use the Operations Manager class libraries to remove any installed Management Pack. Removing a Management Pack also removes its associated rules, tasks, and other content.

Example

The following example demonstrates how to remove a Management Pack that is specified by name.

C#  Copy Code
/// <summary>
/// Removes the specified Management Pack (including its rules and 
/// other associated components).
/// </summary>
using System;
using System.Collections.ObjectModel;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Configuration.IO;
using System.Text;

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

			// Define the Management Pack name.
			string mpName = "Microsoft.Samples.OMSDK.TestMP1";
		
			string query = ("Name = '" + mpName + "'");
			ManagementPackCriteria mpCriteria = new ManagementPackCriteria(query);
		
			ReadOnlyCollection<ManagementPack> mPacks = 
				mg.GetManagementPacks(mpCriteria);
			if (mPacks.Count != 1)
				throw new InvalidOperationException(
					"Error! Expected one Management Pack with: " + query);
		
			mg.UninstallManagementPack(mPacks[0]); 	 
	}
}
}

See Also


Send comments about this topic to Microsoft.