Jaa


How to Remove an Operations Manager Management Pack

 

Updated: May 13, 2016

Applies To: System Center 2012 R2 Operations Manager, System Center 2012 - Operations Manager, System Center 2012 SP1 - Operations Manager

When you no longer need a management pack, you can delete it using the Operations console. When you delete a management pack, all the settings and thresholds associated with it are removed from System Center 2012 – Operations Manager. Also, the .mp or .xml file for that management pack is deleted from the hard disk of the management server. You can delete a management pack only if you have first deleted dependent management packs.

To remove a management pack

  1. Log on to the computer with an account that is a member of the Operations Manager Administrators role.

  2. In the Operations console, click Administration.

  3. In Administration, click Management Packs.

  4. In the Management Packs pane, right-click the management pack you would like to remove and then click Delete.

  5. On the message stating that deleting the management pack might affect the scoping of some user roles, click Yes.

Programmatically remove a management pack with Dependencies

When a management pack is deleted from the administration pane UI, it can become very time consuming to recursively track down and delete all dependent management packs before deleting the originally intended management pack. You can use the following script to cascade delete a management pack and all its dependencies.

To run the script, follow these steps:

  1. Open the Operations Manager Command Shell prompt in Administrator mode.

  2. Run the attached script from the directory where you have saved it in the disk. For example:

    • .\RecursiveRemove.ps1 <ID or System Name of the MP>

    • .\RecursiveRemove.ps1 Microsoft.SQLServer.2014.Discovery

    Note You can see the ID or System Name of the MP that you want to uninstall by selecting it in Installed Management Packs view. Then click Properties in the Actions Pane. Then copy the content in ID: text box in General tab.

# The sample scripts are not supported under any Microsoft standard support 
# program or service. The sample scripts are provided AS IS without warranty 
# of any kind. Microsoft further disclaims all implied warranties including, 
# without limitation, any implied warranties of merchantability or of fitness
# for a particular purpose. The entire risk arising out of the use or 
# performance of the sample scripts and documentation remains with you. In no
# event shall Microsoft, its authors, or anyone else involved in the creation,
# production, or delivery of the scripts be liable for any damages whatsoever
# (including, without limitation, damages for loss of business profits,
# business interruption, loss of business information, or other pecuniary
# loss) arising out of the use of or inability to use the sample scripts or
# documentation, even if Microsoft has been advised of the possibility of 
# such damages.
# PowerShell script to automagically remove an MP and its dependencies.
# Original Author   :       Christopher Crammond
# Modified By       :       Chandra Bose
# Date Created      :   April 24th, 2012
# Date Modified     :   Januray 18th, 2016
# Version       :       0.0.2

# Needed for SCOM SDK
$ipProperties = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()
$rootMS = "{0}.{1}" -f $ipProperties.HostName, $ipProperties.DomainName


#######################################################################
# Helper method that will remove the list of given Management Packs.
function RemoveMPsHelper 
{param($mpList)
  foreach ($mp in $mpList)
  {
    $recursiveListOfManagementPacksToRemove = Get-SCOMManagementPack -Name $mp.Name -Recurse
    if ($recursiveListOfManagementPacksToRemove.Count -gt 1)
    {
        Echo "`r`n"
        Echo "Following dependent management packs has to be deleted before deleting $($mp.Name)..."

        $recursiveListOfManagementPacksToRemove | format-table name
        RemoveMPsHelper $recursiveListOfManagementPacksToRemove
    }
    else
    {
        $mpPresent = Get-ManagementPack -Name $mp.Name
        $Error.Clear()
        if ($mpPresent -eq $null)
        {
            # If the MP wasn’t found, we skip the uninstallation of it.
            Echo "    $mp has already been uninstalled"
        }
        else
        {
            Echo "    * Uninstalling $mp "
            Uninstall-ManagementPack -managementpack $mp
        }
    }
  }
}

#######################################################################
# Remove 'all' of the JEE MPs as well as MPs that are dependent on them.
# The remove is done by finding the base MP (Microsoft.JEE.Library) and finding
# all MPs that depend on it.  This list will be presented to the user prompting
# if the user wants to continue and removing the list of presented MPs
function RemoveMPs
{param($mp)

  $listOfManagementPacksToRemove = Get-SCOMManagementPack -Name $mp -Recurse
  $listOfManagementPacksToRemove | format-table name

  $title = "Uninstall Management Packs"
  $message = "Do you want to uninstall the above $($listOfManagementPacksToRemove.Count) management packs and its dependent management packs"

  $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Uninstall selected Management Packs."
  $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Do not remove Management Packs."
  $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

  $result = $host.ui.PromptForChoice($title, $message, $options, 0) 

  switch ($result)
  {
        0 {RemoveMPsHelper $listOfManagementPacksToRemove}
        1 {"Exiting without removing any management packs"}
  }
}

#######################################################################
# Begin Script functionality
if ($args.Count -ne 1)
{
  Echo "Improper command line arguments"
  Echo ""
  Echo "Specify a command line argument to either import or export MPs"
  exit 1
}
else
{
  $firstArg = $args[0]

  add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";
  $cwd = get-location
  set-location "OperationsManagerMonitoring::";
  $mgConnection = new-managementGroupConnection -ConnectionString:$rootMS;

  RemoveMPs $firstArg

  set-location $cwd
  remove-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client";  
}

Note

If any other imported management packs depend on the management pack you are trying to remove, the Dependent Management Packs error message displays. You must remove the dependent management packs before you can continue.

Operations Manager removes the selected management pack.