大网数据广告活动
启动与系统组件

Remove duplicate Management pack aliases

· 52CE 我爱测

This article describes the procedure to remove duplicate management pack aliases before upgrading to System Center Operations Manager 2019 UR4.

With System Center Operations Manager 2019 UR4 and 2022 RTM, System Center Operations Manager management pack reference aliases are case-sensitive and will create only unique aliases. As a result, System Center Operations Manager update rollup upgrades or version upgrades will fail in an environment where duplicate management pack reference aliases are already present.

This article helps remove the duplicate management pack reference aliases (if present) so that System Center Operations Manager update rollup upgrades or version upgrades complete successfully.

Ensure to remove all duplicate management pack aliases before you upgrade to System Center Operations Manager 2019 UR4.

Detect duplicate management pack aliases

To detect management packs with duplicate management pack aliases, do the following:

Either launch PowerShell ISE on a Management Server or run the T-SQL against System Center Operations Manager Operations Database.

PowerShell Script

############################################
#Identify MPs imported with duplicate Aliases
Import-Module OperationsManager
$mps = Get-SCOMManagementPack
foreach ($mp in $mps)
{
  	$hashTable = @{}
 	 foreach ($ref in $mp.References)
  	{
   	 try {$hashTable.Add($ref.Key, $ref.Value)}
    	catch
    	{
     	 $MPName = $mp.Name
     	 $MPDisplayName = $mp.DisplayName
     	 $MPVersion = $mp.Version
        "MP contains duplicate aliases: Name=($MPName) DiplayName=($MPDisplayName) Version=($MPVersion)"
    	}
  	}
}
############################################ 

T-SQL

-- LIST ALL MPs that have a duplicate Alias reference
DECLARE @mpFriendlyName NVARCHAR(255),
        @mpName         NVARCHAR(255),
        @mpId           UNIQUEIDENTIFIER,
        @mpXml          AS XML

CREATE TABLE #badmptable
  (
     mpid           UNIQUEIDENTIFIER,
     mpname         NVARCHAR(255),
     mpfriendlyname NVARCHAR(255)
  )

DECLARE mp_cursor CURSOR local forward_only read_only FOR
  SELECT mpfriendlyname,
         mpname,
         managementpackid,
         CONVERT(XML, mpxml)
  FROM   managementpack

OPEN mp_cursor

FETCH next FROM mp_cursor INTO @mpFriendlyName, @mpName, @mpId, @mpXml

WHILE @@FETCH_STATUS = 0
  BEGIN
      SELECT n.value('@Alias', 'nvarchar(255)') AS mpRef
      INTO   #temprefs
      FROM   @mpXml.nodes('/ManagementPack/Manifest/References/Reference') AS a(
             n)

      IF EXISTS (SELECT Count(*)
                 FROM   #temprefs
                 GROUP  BY mpref
                 HAVING Count(*) > 1)
        BEGIN
            INSERT INTO #badmptable
                        (mpid,
                         mpname,
                         mpfriendlyname)
            VALUES      ( @mpId,
                          @mpName,
                          @mpFriendlyName )
        END

      DROP TABLE #temprefs

      FETCH next FROM mp_cursor INTO @mpFriendlyName, @mpName, @mpId, @mpXml
  END

CLOSE mp_cursor

DEALLOCATE mp_cursor

SELECT *
FROM   #badmptable

DROP TABLE #badmptable
--End

Scenario 1

If the output of the PowerShell or T-SQL script returns no value, then there are no duplicate management pack aliases. Proceed with UR4 upgrade.

Scenario 2

If the output returns one or more rows, then do the following:

  1. If the management pack is unsealed

    1. Export the management pack from the console.

    2. Open the management pack XML using a text editor.

    3. Identify the duplicate alias.

    4. Rename one of the aliases under Reference and all other places where the alias is used in the XML body.In this example, we have two aliases, which will be considered as duplicates in System Center Operations Manager 2019 UR4.

      :::image type="content" source="./media/remove-duplicate-management-pack-aliases/aliases-example-inline.png" alt-text="Screenshot showing the aliases example." lightbox="./media/remove-duplicate-management-pack-aliases/aliases-example-expanded.png":::

      In order to detect where the aliases are used, search the XML with AliasName. In this case, it's BADALIAS. Note the places where the reference is used.

      Rename one of those aliases to a unique name under Reference and replace all the occurrences of the old name with the new name as detected in the above step.

    5. Once the duplicate aliases are renamed, reimport the management pack to System Center Operations Manager.

  2. If the management pack is sealed

    1. Open the sealed management pack as per the tool of preference.
    2. Identify the duplicate alias.
    3. Rename one of the aliases under Reference and all other places where the alias is used in the XML body.
    4. Rebuild the management pack and reimport in System Center Operations Manager.
    5. The same steps can be done by editing the XML - Sealing the management pack and reimporting the management pack.

Once the mitigation is done on all the management packs, rerun the PowerShell script or the T-SQL script to ensure it returns no output.

Follow the above steps for each management pack returned as output.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 04/15/2024
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。