Retrieving Management Pack Reference Aliases using PowerShell

Retrieving Management Pack Reference Aliases using PowerShell

  • Comments 1
  • Likes

Today I was playing around with some MP Authoring automation using PowerShell and I needed to retrieve the Management Pack Reference Alias within a Management Pack. If you export a Management Pack to XML using the Get-SCOMManagementPack Cmdlet you can view the XML file and its contents.

Get-SCOMManagementPack -Name Stefan.Test.MP | Export-SCOMManagementPack -Path c:\temp

If you look at the exported MP XML file you can see the Management Pack Reference Aliases.

<ManagementPack ContentReadable="true" SchemaVersion="2.0" OriginalSchemaVersion="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <Manifest>
    <Identity>
      <ID>Stefan.Test.MP</ID>
      <Version>1.0.0.0</Version>
    </Identity>
    <Name>Stefan - Test MP</Name>
    <References>
      <Reference Alias="MicrosoftWindowsLibrary7585010">
        <ID>Microsoft.Windows.Library</ID>
        <Version>7.5.8501.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="SystemLibrary7585010">
        <ID>System.Library</ID>
        <Version>7.5.8501.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="SystemCenter">
        <ID>Microsoft.SystemCenter.Library</ID>
        <Version>7.0.8432.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Health">
        <ID>System.Health.Library</ID>
        <Version>7.0.8432.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="MicrosoftSystemCenterInstanceGroupLibrary7585010">
        <ID>Microsoft.SystemCenter.InstanceGroup.Library</ID>
        <Version>7.5.8501.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
    </References>

But you know me, I don’t want to export the XML file and open it to see the Reference Aliases Smile We have  PowerShell so we are going to use it.

How can we retrieve this info using PowerShell in the PowerShell OperationsManager Console?

$mp = Get-SCOMManagementPack -name Stefan.Test.MP

$alias = ($mp.References | where {$_.Value -like "*Microsoft.Windows.Library*"}).key

$alias

This will give us the Alias for the Microsoft.Windows.Library.

image

Next time more on how we could use this information to do some MP Authoring automation.

 

Have a nice Easter weekend and maybe I see you at MMS in Las Vegas or the PowerShell Summit in Redmond!

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • That very useful code, thanks Stefan.