如何删除操作管理器管理包

 

发布时间: 2016年3月

适用对象:System Center 2012 R2 Operations Manager, System Center 2012 - Operations Manager, System Center 2012 SP1 - Operations Manager

当您不再需要管理包时,您可以将其使用操作控制台删除。 删除管理包时,所有设置和与之关联的阈值都会从 System Center 2012 – Operations Manager。 此外,该管理包的.mp 或.xml 文件是从管理服务器的硬盘中删除。 仅当您第一次删除从属管理包,可以删除管理包。

若要删除的管理包

  1. 使用一个特定帐户登录计算机,该帐户是 Operations Manager 管理员角色的成员。

  2. 在操作控制台中,单击“管理”。

  3. 管理, ,请单击 管理包。

  4. 管理包 窗格中,右键单击该管理包您想要删除,然后单击 删除

  5. 在消息,指出,删除管理包可能会影响某些用户角色的作用域,单击

以编程方式移除具有依赖关系的管理包

当从管理窗格用户界面中删除管理包时,它可以变得很费时间以递归方式跟踪向下和在删除最初预期的管理包之前删除所有从属管理包。 可以使用以下脚本以级联删除管理包和所有依赖项。

若要运行该脚本,请按照下列步骤 ︰

  1. 在管理员模式下打开 Operations Manager 命令外壳提示符。

  2. 在保存它在磁盘从目录运行附加的脚本。 例如:

    • .\RecursiveRemove.ps1 < ID 或系统的管理包名称 >

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

    注意 ID 或你想要卸载中进行选择的管理包系统名称,您可以看到 安装管理包 视图。 然后单击 属性 操作窗格中。 然后将复制中的内容 ID: 文本框一般选项卡。

# 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";  
}
System_CAPS_note注意

如果任何其他导入的管理包依赖于尝试删除的管理包 从属管理包 将显示错误消息。 您可以继续操作之前,必须删除依赖管理包。

Operations Manager 删除所选的管理包。