OpsMgr 2012 – how to dump management pack bundles

With the release date of System Center 2012 getting closer, we’re upgrading our tools to the new version. As it always happens for new products, even if documentation is going to be good, it will not be enough especially for advanced topics. With Management Pack development this is especially true- Since the first way to understand new techniques is learning from others, or if you want via reverse engineering, one of the first steps to achieve this is to get access to MP contents and indeed we had several scripts in the community to do this . With Operations Manager 2012, a new format for MPs has been introduced: Management Pack Bundles (.mpb files). Actually Service manager had MPBs since a long time. The old scripts to dump the content of an MP file need to be updated to dump MPB as well.

With this post I’m going to share an handy powershell script that will allow to dump of both MP and MPB files for both OpsMgr and Service Manager. The script will take just two parameters an input directory where you have to copy MP and MPB files and an output directory where the dumps will be saved. The OpsMgr 2012 admin console needs to be installed for the script to work  properly.

You can find the script here:  https://www.sugarsync.com/pf/D6284134_0813286_659567

param($inDir, $outDir)


$mpStore = new-Object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackFileStore($inDir)

$mps = get-childitem $inDir *.mp
$mpWriter = new-object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($outDir)
if ($mps -ne $null)
    foreach ($file in $mps)
        $MPFilePath = $file.FullName
        $mp = new-object Microsoft.EnterpriseManagement.Configuration.ManagementPack($MPFilePath)
        Write-Host $file
#now dump MPB files
$mps = get-childitem $inDir *.mpb
$mpbReader = [Microsoft.EnterpriseManagement.Packaging.ManagementPackBundleFactory]::CreateBundleReader()
if ($mps -ne $null)
    foreach ($file in $mps)
        $mpb = $mpbReader.Read($file.FullName, $mpStore)
        foreach($mp in $mpb.ManagementPacks)
            #write the xml
            $streams = $mpb.GetStreams($mp)
            foreach($stream in $streams.Keys)
                $mpElement = $mp.FindManagementPackElementByName($stream)
                $fileName = $mpElement.FileName
                if ($fileName -eq $null)
                    $fileName = $outDir +’\’ + ($mp.Name)+ ‘.’ + $stream+ ‘.bin’
                    If ($fileName.IndexOf(‘\’) -gt 0)
                        #only on dir level supported
                        $dir = $outDir + ‘\’ + $fileName.SubString(0, $fileName.IndexOf(‘\’))
                        if ([System.Io.Directory]::Exists($dir) -ne $true)
                    $fileName = "${outdir}\${fileName}"
                Write-Host "`t$fileName"
                $fs = [system.io.file]::Create($fileName)


– Daniele

This posting is provided "AS IS" with no warranties, and confers no rights.

About these ads
  1. #1 by Stefan Stranger on March 6, 2012 - 4:18 pm

    Hi Daniele,

    Thanks for sharing this great script to dump the contents of the MPB files. To fit my personal preferences I made some small changes to your script. Hope you don’t mind. If so let me know and I’ll remove it from my blog.

    For the changes see my blogpost: http://blogs.technet.com/b/stefan_stranger/archive/2012/03/06/opsmgr-2012-how-to-dump-management-pack-bundles-small-improvement.aspx


    • #2 by Daniele Grandini on March 6, 2012 - 5:58 pm

      Hi Stefan,
      this is a great example of community contribution. Thanks for reading my blog and sharing your improvements.

      – Daniele

  1. Inside Management Packs | code4ward.net
  2. Inside Management Packs | code4ward.net
  3. Fixing missing stored proecdures for dashboards in the datawarehouse | Jan's System Center Blog
  4. Silect MP Studio 5.1 – First look at the new MPB support | smct GmbH
  5. Article d’Alban MONTANERA sur la compatibilité des packs d’administration - WebLog de Stéphane PAPP [MSFT] - Site Home - MSDN Blogs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 410 other followers

%d bloggers like this: