This script is provided "as is" for the purpose of illustrating how product tasks may be performed in conjunction with PowerShell. Support shall not be liable for any direct, indirect, incidental, consequential, or other damage alleged in connection with the furnishing or use of this script or of the principles it demonstrates. See PowerShell Scripting Support for more information.
A simple powerShell script has been prepared. A version of this script has been used to compile in excess of 1000 mof files in a real life situation.
The script reads all mof files on the system it runs, remove those that contain the words "uninstall","unregister" and "remove" in their names and save them in a file called "C:\temp\rawmofs.txt". This file is created only for further processing outside the script, if necessary.
At the same time the current WMI repository is backed up for safety in "c:\temp\WMIRepo_.bak", where is an unique identifier. This allows multiple runs of the script, for instance when a step by step WMI rebuild is performed and returning to the previous WMI repository state is needed in case of something goes wrong.
Once the mof collection operation finishes, the list is automatically opened for editing in grid view, which allows filtering the mof list. The result can be saved through a save file dialog. The edited file or any other mofs file can be selected through an "open file" dialog. The mof file paths contained in this file are loaded into memory and compiled one by one.
The script requires PowerShell 3.0 or later.
The PowerShell code is shown below and attached to the KB article.
© 2025 Quest Software Inc. ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center