How to Remove an Existing Management Pack
Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007
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.
/// <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
Tasks
How to Import a New Management Pack