Home > Operations Manager, PowerShell > Extracting information from a SCOM Management Pack

Extracting information from a SCOM Management Pack

On reddit someone on the SCOM channel asked how to pull specifically PowerShell script from a management pack. If you have a sealed mp file first it will need to be extracted to an xml file. To do this we will use the power of MP Viewer a utility that I use almost every day.

MP Viewer can be downloaded from Microsoft TechNet Gallery here.

Please note the SCOM Console will need to be installed on the system you plan on running MP Viewer from. On that system fire up MP Viewer and open and MP File. once it has finished loading the mp file, click File –> Unseal/Unpack Management Pack option, select the destination where the file will go, I usually keep the default name of the xml file and put it in the same folder where the MP file is found.

Also check out Jonathan Almquist blog he wrote a similar script back in 2012 http://blog.scomskills.com/output-list-of-scripts-contained-in-a-management-pack/

The easiest way to get all the scripts from the xml file would naturally be to run the PowerShell script which is saved to my C:\Temp3\scriptsfrommps.ps1 below:

[xml] $SQLMP = Get-Content -Path C:\temp3\Microsoft.SQLServer.2012.Monitoring.xml

$ScriptName = $SQLMP.SelectNodes(“//ScriptName”).”#text”

$ScriptBody = $SQLMP.SelectNodes(“//ScriptBody”).”#text”

for ($i=0; $i -lt $SQLMP.SelectNodes(“//ScriptName”).count; $i++)

{

$ScriptBody[$i] >> $ScriptName[$i]

}

Now my C:\Temp3 folder will be littered with the scripts from the SQL Server 2012 Monitoring MP. Just have to change the first line to which ever management pack that you would like to inspect.

Enjoy!

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment