PowerShell Script to Import MPBs into SCOM 2012 Beta (v2)

PowerShell Script to Import MPBs into SCOM 2012 Beta (v2)

  • Comments 1
  • Likes

In a previous posting, I provided a PowerShell script to import and remove MP(B)s.  The brunt of that posting focused on the logic for importing MPBs because this is the new feature for SCOM 2012.  The logic for removing the MPs "worked" for my limited development purposes, but could be improved.

Inspired by the efforts of a co-worker, I have revised the PowerShell script to recursively remove all Management Packs dependent on the Microsoft.JEE.Library management pack (bundle).  Prior to removing the MPs, the user is prompted with a list of all dependent MPs and must agree to deleting said files.

 #######################################################################
#
# Remove 'all' of the JEE MPs as well as MPs that are dependent on them.
# The remove is done by finding the base MP (Microsoft.JEE.Library) and finding
# all MPs that depend on it. This list will be presented to the user prompting
# if the user wants to continue and removing the list of presented MPs
#
function RemoveMPs
{
Import-Module 'C:\Program Files\System Center Operations Manager 2012\Powershell\OperationsManager\OperationsManager.psd1'

$listOfManagementPacksToRemove = Get-SCOMManagementPack -Name Microsoft.JEE.Library -Recurse
$listOfManagementPacksToRemove | format-table name

$title = "Uninstall Management Packs"
$message = "Do you want to uninstall the above management packs"

$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Uninstall selected Management Packs."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Do not remove Management Packs."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

$result = $host.ui.PromptForChoice($title, $message, $options, 0)

switch ($result)
{
0 {RemoveMPsHelper $listOfManagementPacksToRemove}
1 {"Exiting without removing any management packs"}
}
}
Attachment: JeeMpHelper.txt
Comments
  • Update: for the RTM code, some paths on disk for the above script have changed.

    Previously it was:

    'C:\Program Files\System Center Operations Manager 2012\Powershell\OperationsManager\OperationsManager.psd1

    Now it is:

    C:\Program Files\System Center 2012\Operations Manager\Powershell\OperationsManager\OperationsManager.psd1

    P.S. Obviously: the drive will depending on your installation

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment