Automate management packs using powershell

I’ve been asked on a few occasions to automate management packs. Unfortunately, there isn’t much information about how to do to do this using Powershell in the MSDN development kit. I am providing a couple Powershell functions you can add to your automation process that will generate a new management pack.

Just update the output directory, pack name, pack display name, and version in the highlighted lines.

 

function CreateNewPack ($id, $name, $version) {
    $mpStore = New-Object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackFileStore
    $managementPack = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPack($id, $name, (New-Object Version(1,0,0,$version)), $mpStore)
    $managementPack.DefaultLanguageCode = 'ENU'
    $managementPack.DisplayName = $name
    $managementPack.Description = $name + ' management pack was auto-generated'
    $managementPack
}
function WriteManagementPack ($directory, $mp) {
    $mpWriter = new-object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($directory)
    $mpWriter.WriteManagementPack($mp) | Out-Null
}
$directory = 'c:\My Pack'
$mp = CreateNewPack 'MyNewPack' 'My New Pack' 1
$mp.AcceptChanges()
WriteManagementPack $directory $mp

Contact SCOMskills if you are interested in learning more about management pack automation, at automation@scomskills.com.

 

🙂

5 thoughts on “Automate management packs using powershell”

    1. Is there a switch or configuration you can add to this so that the MP does not appear in the monitoring pane of the SCOM console? Many time I create MP for over rides and I do not want this MP to appear the SCOM console.

Comments welcome (links require moderation)