MP reference cleanup from unsealed MP

Stumbled upon this really cool stand alone powershell script by Tao Yang that removes obsolete references from unsealed SCOM management packs.

link to script

There is another version available by Matthew Dowst but the differences in the versions are as follows:-

No need to export and re-import unsealed management packs: My script directly reads and updates MP contents using SCOM SDK. therefore unsealed MPs don’t need to be exported and re-imported.
Scan through all unsealed MPs: My script go through all unsealed MPs rather than individual XML files.
Option to backup MPs before changes are made: the script accept parameters to backup original unsealed MPs before any changes are made.
Option to increase MP version or keep version the same: Users can choose whether the MP version should be increased.
Allow test run (-WhatIf): Users can use –WhatIf switch to test run the script before changes are made.
MP Verify: the script verifies the MP before and after changes. if MP verify fails (including pre-existing errors), no changes will be made to the particular MP.
Allow Users to customize a “white list” for common MPs: When obsolete references are detected for the “common management packs” defined in the CommonMPs.XML (placed in the same folder as the script), these references will be ignored. This is because these common management packs are referenced in many out-of-box unsealed management packs by default. Additionally, since it is very unlikely these management packs will ever be deleted from the management group, therefore it should not be an issue when they are referenced in other management packs. Users can manually add / remove MPs from the list by editing the CommonMPs.XML. I have pre-populated the white list and included the following MPs:
Microsoft.SystemCenter.Library
Microsoft.Windows.Library
System.Health.Library
System.Library
Microsoft.SystemCenter.DataWarehouse.Internal
Microsoft.SystemCenter.Notifications.Library
Microsoft.SystemCenter.DataWarehouse.Library
Microsoft.SystemCenter.OperationsManager.Library
System.ApplicationLog.Library
Microsoft.SystemCenter.Advisor.Internal
Microsoft.IntelligencePacks.Types
Microsoft.SystemCenter.Visualization.Configuration.Library
Microsoft.SystemCenter.Image.Library
Microsoft.SystemCenter.Visualization.ServiceLevelComponents
Microsoft.SystemCenter.NetworkDevice.Library
Microsoft.SystemCenter.InstanceGroup.Library
Microsoft.Windows.Client.Library

Instruction:

You can run this script on any computers have OpsMgr 2012 console /agent / management server installed. The script includes a help documentation. you can access it via:

get-help .\MPReferencesCleanUp.ps1 –full

MPcleanup1

Examples:

#1. Test run using -WhatIf: .\MPReferencesCleanUp.ps1 -ManagementServer “OPSMGRMS01” –BackupBeforeModify –BackupLocation “C:\Temp” -IncrementVersion –WhatIf

MPcleanup2

#2. Real run without –WhatIf: .\MPReferencesCleanUp.ps1 -ManagementServer “OPSMGRMS01” –BackupBeforeModify –BackupLocation “C:\Temp” –IncrementVersion

MPcleanup3

Credits

Credits to Tao Yang and the following people (in random order)

Cameron Fuller, Raphael Burri, Marnix Wolf, Bob Cornelissen, Dan Kregor, Matthew Dowst, Matthew Long

Advertisements
This entry was posted in Management Packs, Powershell for SCOM and tagged , , , , , , , , , , , , . Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s