Freigeben über


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

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"}
 }
 }
 

JeeMpHelper.txt

Comments

  • Anonymous
    January 01, 2003
    Update: for the RTM code, some paths on disk for the above script have changed. Previously it was: 'C:Program FilesSystem Center Operations Manager 2012PowershellOperationsManagerOperationsManager.psd1 Now it is: C:Program FilesSystem Center 2012Operations ManagerPowershellOperationsManagerOperationsManager.psd1 P.S. Obviously: the drive will depending on your installation