Share via


How to Remove an Existing Management Pack

Applies To: System Center 2012 - Operations Manager

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

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.Generic;
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);
            
            IList<ManagementPack> mPacks = 
                mg.ManagementPacks.GetManagementPacks(mpCriteria);
            if (mPacks.Count != 1)
                throw new InvalidOperationException(
                    "Error! Expected one Management Pack with: " + query);
            
            mg.ManagementPacks.UninstallManagementPack(mPacks[0]);           
        }
    }
}

See Also

Tasks

How to Import a New Management Pack

Other Resources

Automating Management Pack Development