How can I reconstruct the WMI classes?

How can I reconstruct the WMI classes?

Managed Object Format (MOF) files define the Windows Management Instrumentation (WMI) classes stored in the WMI repository. If the repository becomes corrupted or the WMI class definitions are damaged, WMI queries may fail or return incomplete data, resulting in monitoring failures.

This article explains how to repair or rebuild the WMI repository on the target Windows server.

NotesNote: Rebuilding the WMI repository should be performed only if repairing the repository does not resolve the issue.

Rebuild the WMI Repository

Step 1: Stop the WMI Service

Disable and stop the Windows Management Instrumentation service.


Step 2: Back Up the Existing Repository

Create a backup of the following directory:

Info
C:\%windir%\System32\wbem\Repository

Step 3: Re-register WMI Components

  1. Open Command Prompt with Run as Administrator.
  2. Navigate to the following directory:
Quote
cd C:\%windir%\System32\wbem
  1. Execute the following commands one by one:
Quotefor /f %s in ('dir /b /s *.dll') do regsvr32 /s %s
for /f %s in ('dir /b /s *.mof') do mofcomp %s
for /f %s in ('dir /b /s *.mfl') do mofcomp %s

Step 4: Start the WMI Service

Enable and start the Windows Management Instrumentation service.

NotesNote: If required, replace %windir% with the appropriate Windows installation directory for your operating system.
Operating SystemWindows Directory
Windows 2000winnt
Windows XP, Windows Server 2003, Windows Server 2008windows
Other Windows versionsWindows

Verify the WMI Repository

  1. Open Command Prompt with Run as Administrator.
  2. Execute the following command:
Quote
winmgmt /verifyrepository

Result Interpretation

If the following message is displayed:

Info
WMI Repository is consistent

the repository is healthy, and the issue is likely caused by another WMI component.

If any other message is returned, continue with the repair steps below.


Repair the WMI Repository

Step 1: Attempt to Repair the Repository

Run the following command:

Quote
winmgmt /salvagerepository

If the repair is successful, verify whether the monitoring issue has been resolved.


Step 2: Reset the Repository (if Repair Fails)

If the previous command does not resolve the issue:

  1. Stop the Windows Management Instrumentation service.
  2. Execute the following command:
Quote
winmgmt /resetrepository

If the reset is successful, the following message is displayed:

Info
WMI Repository has been reset


  1. Start the Windows Management Instrumentation service.
  2. Verify that WMI queries execute successfully.

Additional commands for older Windows versions

Windows Server 2003

Execute the following commands:

Quote
wmiadap /f
lodctr /R

Windows 2000 / Windows XP

Execute the following commands:

Quote
winmgmt /clearadap
winmgmt /kill
winmgmt /regserver
winmgmt /resyncperf

Verification

After repairing or rebuilding the repository:

  • Verify that the Windows Management Instrumentation service is running.
  • Execute the required WMI query using WBEMTest.
  • Retry adding the monitor or perform a manual poll of the reported monitor, and verify that data is collected successfully.
  • Confirm that the reported WMI error is no longer observed.

Microsoft References

For additional information, refer to the following Microsoft article:

                    New to ADSelfService Plus?

                      • Related Articles

                      • Windows Monitoring - FAQ

                        This Knowledge Base article provides answers to frequently asked questions about Windows Server monitoring using WMI mode. The articles are organized by the monitoring lifecycle to help you quickly identify the relevant troubleshooting guide. ...
                      • WMI Query and Class Validation Errors

                        Applicable WMI Error Codes 0x80041017 - Invalid Query 0x80041010 - Invalid Class Overview This error occurs when the WMI query executed during monitor addition or data collection is invalid, references unavailable WMI classes or performance counters, ...
                      • WMI Error Troubleshooting Guide

                        This Knowledge Base provides troubleshooting guidance for commonly encountered Windows Management Instrumentation (WMI) errors that may occur while adding a Windows monitor or collecting metrics using WMI mode in Applications Manager. WMI errors can ...
                      • WMI Namespace and Provider Errors

                        Applicable WMI Error Codes 0x8004100E - Invalid Namespace Overview This error occurs when the specified WMI namespace cannot be found or accessed during monitor addition or data collection. An incorrect namespace, a missing or unregistered WMI ...
                      • Unable to retrieve data - WMI Mode

                        This article provides troubleshooting steps to identify and resolve data collection failures for Windows monitors configured in WMI mode. If one or more metrics are not being collected, the steps in this article will help determine whether the issue ...