Share via


如何移除作業管理員管理封包

 

發佈時間: 2016年3月

適用於: System Center 2012 R2 Operations Manager, System Center 2012 - Operations Manager, System Center 2012 SP1 - Operations Manager

當您不再需要管理組件時,您可以刪除使用 Operations 主控台。 當您刪除管理組件時,移除所有的設定和與其相關聯的臨界值從 System Center 2012 – Operations Manager。 此外,就會從管理伺服器的硬碟刪除該管理組件的.mp 或.xml 檔案。 只有當您第一次刪除相依管理組件,您可以刪除管理組件。

若要移除管理組件

  1. 使用屬於 Operations Manager 系統管理員角色成員的帳戶登入電腦。

  2. 在 Operations 主控台中,按一下 [系統管理]。

  3. 管理, ,按一下 [ 管理組件。

  4. 管理組件 ] 窗格中,以滑鼠右鍵按一下管理組件,您想要移除,然後按一下 刪除

  5. 在訊息,說明,刪除管理組件可能會影響某些使用者角色的範圍,按一下 [

以程式設計方式移除相依性的管理組件

刪除管理組件時,系統管理] 窗格 UI,可變得很浪費時間以遞迴方式追蹤,關閉並刪除原本預期的管理組件之前先刪除所有相依的管理組件。 管理組件及其所有相依性,您可以使用下列指令碼來串聯刪除。

若要執行指令碼,請依照下列步驟執行 ︰

  1. 系統管理員模式開啟 Operations Manager 命令殼層提示字元。

  2. 執行附加的指令碼從目錄中儲存它。 例如:

    • .\RecursiveRemove.ps1 < 識別碼或系統管理組件名稱 >

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

    注意 識別碼或您想要解除安裝中,選取管理組件系統名稱,您可以看到 安裝管理組件 檢視。 然後按一下 [ 屬性 動作] 窗格中。 然後將複製的內容 識別碼 ︰ 文字方塊中的一般索引標籤。

# 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 中移除選取的管理組件。