Stumbled upon this really cool stand alone powershell script by Tao Yang that removes obsolete references from unsealed SCOM management packs.
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:
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
#1. Test run using -WhatIf: .\MPReferencesCleanUp.ps1 -ManagementServer “OPSMGRMS01” –BackupBeforeModify –BackupLocation “C:\Temp” -IncrementVersion –WhatIf
#2. Real run without –WhatIf: .\MPReferencesCleanUp.ps1 -ManagementServer “OPSMGRMS01” –BackupBeforeModify –BackupLocation “C:\Temp” –IncrementVersion
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