Bulk Import Operations Manager 2012 Management Packs

It is rare these days that you only need to import a single management pack into SCOM. Management packs like Windows Server Base, SQL Server and others come with 8 or more management packs. The job can get tedious when you have to do it over and over again.

I searched the internet for help and found a single post by Stefan Roth that shows how to import a list of management packs using Import-SCOMManagementPack. One of the benefits of this method is that the list of management packs are automatically imported in the correct order, so if you have a Library management pack that if referenced by a another management pack in the list, the library management pack will be imported first, neat!

After several hours in the lab, I experienced multiple failures, which turned out to be that there were existing management packs already imported, which caused the cmdlet to fail.

I have created a new PowerShell script that will pull in the list of management packs from a folder and compare the list to already installed management packs. So, this script will only import the management packs that are missing.

To start, you need to download and install the management packs on the Operation Manager management server you will be running the script from. If you do not want to manually download the management packs,  you use this PowerShell script available here from Stanislav Zhelyazkov.

I am working on a PowerShell Desired State Configuration (DSC) version of the script that will do all the above, but will have to save that for another post, so stay tuned!

param
(
    [string] $mpdir
)

#$mpdir = “C:\Files\6.4.1.0”
$mpfiles = (Get-Item -Path “$mpdir\*” -Include *.mp*).Name
$mpcnt = $mpfiles.Count

Write-Host “Script is requesting to import $mpcnt management packs.”

$InstallList = @()
$InstalledMPs = Get-SCOMManagementPack |%{$_}|%{$_.name}
foreach ($ManagementPack in $mpfiles)
{
    $mpname = [System.IO.Path]::GetFileNameWithoutExtension($ManagementPack)
    If ($InstalledMPs -notcontains $mpname) {
        Write-Host “$ManagementPack is missing, adding to installation queue.”
        $InstallList += $ManagementPack
    }
    Else
    {
        Write-Host “$ManagementPack is already installed!”
    }
}

$Instcnt = $InstallList.Count

If ($Instcnt -gt 0)
{
    Write-Host “$Instcnt management packs were added to installation queue, installing now…”
    Set-Location $mpdir
    Import-SCOMManagementPack -Fullname $InstallList -ErrorAction SilentlyContinue
}

One thought on “Bulk Import Operations Manager 2012 Management Packs

  1. Davey Rance

    Hi Joe

    Great entry.  a couple of suggestions.  If you are doing a whole bulk import it may be better to do a recurse of the folder structure.  Also including xml files so that way your overrides can come in at the same time.

    Change the $Mpfiles line to this.

    $mpfiles = Get-childItem -Path “$mpdir\*” -Include *.mp*,*.xml -Recurse

    Then you will need to make a small change for the line that gets the mp name.

    $mpname = $ManagementPack.basename

    and add in the full path to the $installlist variable

    $InstallList += $ManagementPack.fullname

    With those 3 small changes you can now have a nice folder structure with your overrides and import it all in one go 🙂

    Davey

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.