Compartilhar via


How to Uninstall a Management Pack

Uninstalling a management pack is as easy as installing one. Although only few calls are required to remove the management pack, any external files such as form binaries and workflow binaries are not uninstalled when you uninstall it. To remove these components you must manually delete them. If other management packs are referencing the management pack you want to uninstall, the uninstall will fail. To identify which management packs may be blocking the uninstall, use the GetDependentManagementPacks method from the ManagementPacks property on the management group object.

To load and uninstall a management pack bundle

  1. Create a new bundle reader from the bundle factory.

  2. Read the bundle file.

  3. Uninstall the bundle from the management group.

The following example demonstrates how to load and uninstall a management pack bundle.

EnterpriseManagementGroup mg = new EnterpriseManagementGroup("localhost");
ManagementPackBundle bundle;
ManagementPackBundleReader bundleReader = ManagementPackBundleFactory.CreateBundleReader();
string bundleFile = @".\RePackaging.Library.mpb";

bundle = bundleReader.Read(bundleFile, mg);
mg.ManagementPacks.UninstallBundle(bundle);

Namespaces

Microsoft.EnterpriseManagement

Microsoft.EnterpriseManagement.Packaging

Assemblies

Microsoft.EnterpriseManagement.Core

Microsoft.EnterpriseManagement.Packaging

To uninstall a management pack object

  1. Call the UninstallManagementPack method on the IManagementPackManagement object which is implemented in the management group by the ManagementPacks property.

As long as you have access to a management pack object, regardless of how it was obtained, you can uninstall it. The following example demonstrates how to uninstall a management pack object after you have a reference to it.

managementGroup.ManagementPacks.UninstallManagementPack(managementPack);

Namespaces

Microsoft.EnterpriseManagement.Configuration

Microsoft.EnterpriseManagement

Microsoft.EnterpriseManagement.Packaging

Assemblies

Microsoft.EnterpriseManagement.Core

Microsoft.EnterpriseManagement.Packaging