Cleaning up unused management packs.

I recently did some house keeping in our OpsMgr environment, cleaning up old and unused Management Packs, and to easily identify potential unused Management Packs I of course turned to PowerShell!

This script can walk through the management packs and get the number of instances for each class. If there is no instances of a class it is very likely that it is not used. After running this script you will end up with a list of potential unused classes, you can now check each management pack for it’s content and see if there is other classes in it that is in use.

################################################################
#   Author: Andreas Sobczyk, CloudMechanic.net
#
#   Get Empty classes from Management Packs
################################################################

## Get all management packs starting with Contoso.
$MPs = Get-SCOMManagementPack -name Contoso*

## For each MP, For each Class, count classinstances.
$Overview = @()
Foreach($MP in $MPs){
$Classes = $mp.GetClasses()

foreach($Class in $Classes){
$ClassInstance = $null
$ClassInstance = Get-SCOMClassInstance -Class $class

## If you want you can change the number of class instances to sort on.
if($ClassInstance.Count -le 0){
$Overview += $Class
}
}
}

$Overview | Format-Table Name,Displayname,ManagementpackName

GitHub Download

5 thoughts on “Cleaning up unused management packs.

  1. Couldn’t get this to work on SCOM2016. Has the Get-SCClassInstance CMDlet been removed? I find no reference to it. Any ideas as this sounds like a useful script 🙂

    Thank you.

    The error:
    Get-SCClassInstance : The term ‘Get-SCClassInstance’ is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At G:\xSCRIPTS\GetSCOMUnusedClasses_MPs.ps1:17 char:18
    + $ClassInstance = Get-SCClassInstance -Class $class
    + ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-SCClassInstance:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Like

      • Awesome Andreas, thank you for looking into that so quickly! With the $Overview variable, I only ever see 2x columns DisplayName and Name. So the Format-Table only in-effect reverses the order of the 2x columns.

        Not sure if that’s an error or expected, in which case maybe don’t need the ManagementpackName?

        From:
        DisplayName, Name

        To:
        Name, DisplayName

        Would be cool for you to add a screnshot of the expected output to your post and markdown file, as an idea.

        Thanks again!

        Like

  2. My mistake. Just running line 26 as:
    $Overview | Format-Table

    Shows there are more than 2 columns, including ManagementpackName.

    Even with -Wrap and -Autosize I don’t see the output in the terminal window at least. But otherwise, it works 🙂

    Like

  3. Great info. What I am looking for is a way to list all HyperV network settings of a current running system – virtual switch, virtual NIC, Mac address, etc. Does anybody know of such a utility? Looking for similar utilities for SQL and Exchange, Windows networking, etc.? In summary a list of Windows settings so I can compare two systems that should be similar – same OS, same apps – to find out in fact if there are any significant differences between their settings in side by side comparison of settings relevant to the particular module/component so able to compare Exchange settings side by side.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s