I originally blogged on this for OpsMgr 2007 R2 which is available at: http://www.systemcentercentral.com/BlogDetails/tabid/143/IndexID/67980/Default.aspx. In OpsMgr 2012 there are updated PowerShell scripts so it was time to get an update done for this blog post. In the original scenario I had added a bunch of management packs named with test that I needed to remove. So here’s how to remove them by name in OpsMgr 2007 and 2012:

OpsMgr 2007 PowerShell syntax to list all MP’s with display names that include test:

Get-managementpack | where{$_.displayname –like “*Test*”}

PowerShell in OpsMgr 2012 to list all MP’s with display names that include test: (with Get-managementpack changed to Get-SCOMManagementPack)

Get-SCOMManagementPack | where{$_.displayname -like "*Test*"}

Additionally, more than once I have accidentally added all of the non-English management packs due to choosing the wrong option while using the management pack import wizard (hint: don’t click on a top level management pack and choose add in the management pack import wizard without checking what is under that management pack name). How do we list these management packs and remove them?

PowerShell syntax to show all non-English Management Packs currently in the environment:

Get-SCOMManagementPack | where{$_.defaultlanguagecode -notlike "ENU"}

PowerShell syntax to remove all non-English Management Packs currently in the environment:

Get-SCOMManagementPack | where{$_.defaultlanguagecode -notlike "ENU"} | Remove-SCOMManagementPack

Do not use this in a production environment without fully testing this as this command done incorrectly could remove all management packs from the environment.

[Quick-bonus-PowerShell example] PowerShell syntax to show all Management Packs matching a specific name:

Get-SCOMManagementPack | where{$_.name -like "Microsoft.Windows.Server.2008*"}

Thank you to Ambers Ferrara for his idea on this and syntax for the various examples!