How can I reconstruct the WMI classes?

How can I reconstruct the WMI classes?

Overview

The Managed Object Format (MOFfiles define the Windows Management Instrumentation (WMIclasses that are 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.

Info
Notes: 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:

Quote
C:\%windir%\System32\wbem\Repository
Step 3: Re-register WMI Components
  1. Open Command Prompt with Run as Administrator and navigate to the following directory:


    Quote
    cd C:\%windir%\System32\wbem

  2. Execute the following commands one by one:

    for /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.

Notes

When using the commands above, replace %windir% with the appropriate Windows installation directory if required:

Operating SystemWindows Directory
Windows 2000winnt
Windows Server 2003, Windows XP, 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:

    WMI Repository is consistent

    The repository is healthy. 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: 

    Quote
    winmgmt /resetrepository

  3. If successful, the following message is displayed:

    WMI Repository has been reset


  4. Start the Windows Management Instrumentation service and verify whether 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:

  1. Verify that the Windows Management Instrumentation service is running.
  2. Execute the required WMI query using WBEMTEST.
  3. Retry monitor addition or perform a manual poll for Reported Monitor & check data is fetched.
  4. Confirm that the reported WMI error is no longer observed.

Microsoft References

For additional information, refer to the following Microsoft articles:


                    New to ADSelfService Plus?

                      • Related Articles

                      • Windows Monitoring - FAQ

                        This Knowledge Base article provides answers to frequently asked questions related to Windows Server monitoring through WMI. The articles are categorized based on the monitoring lifecycle to help you quickly identify the relevant troubleshooting ...
                      • 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

                        Overview 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 through WMI mode in Applications Manager. WMI ...
                      • Configuring non-admin user account for WMI monitoring

                        By default, Windows allows only members of the Administrators or Domain Admin groups to read WMI class information. However, you can configure a regular user to access WMI information by performing the following steps on the server that needs to be ...
                      • Setting WMI access through Active Directory and Group Policy Object for non-admin user

                        In our case, we run Active Directory on Windows 2008 R2 and we want to scan the target machine which is Windows 2012 R2 machine. Our domain is called “APMCLU” and we name our dedicated WMI user-account “wmiuser”. First – Setting done from Active ...