How can I reconstruct the WMI classes?

How can I reconstruct the WMI classes?

Managed Object Format (MOF) file is the mechanism by which information about WMI classes is entered into the WMI Repository. It is possible that the class definitions currently in the Repository somehow do not show up the values. In this case, recompiling your .MOF files will cause those class definitions to be overwritten and replaced with the same, uncorrupted class definitions used when the operating system was originally installed.

To repair/re-sync the WMI repository, please follow the steps given below: 

1. Open the Command Prompt with administrator privileges. 
2. Verify whether the WMI repository is corrupted by running the below command : 
winmgmt /verifyrepository
If the repository is not corrupted, a WMI Repository is consistent message will be returned. If the repository is consistent, the repository is not the problem. You will have to check your server for other issues. If you get any other message, go to step 3.
3. Execute the below command to repair the WMI repository: 
winmgmt /salvagerepository
If the above command fails to work, on the remote windows server, stop the Windows Management Instrumentation service and execute the below command:
winmgmt /resetrepository


 After the last command, you should see a WMI Repository has been reset message. This will verify whether the command was successful. After this, start the Windows Management Instrumentation service.

If not, you will see the following output:


If you're using any of the following Windows versions, choose execute the specified commands: 

For Windows 2003:
1. wmiadap /f
2. lodctr /R

For Windows 2000/XP :
1. winmgmt /clearadap
2. winmgmt /kill
3. winmgmt /regserver
4. winmgmt /resyncperf

To reconstruct the WMI repository, please follow the steps given below:

1. On the remote windows server, disable and stop the Windows Management Instrumentation service.
2. Take a backup of C:\%windir%\System32\wbem\Repository directory.
3. Open the Command Prompt with administrator privileges and execute the below commands one by one to reconstruct all the WMI classes:
cd C:\%windir%\system32\wbem
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
Note: In the above commands, replace %windir% [Windows Directory name] with:
  1. windows in case of Windows 2003/XP/2008
  2. winnt in case of windows 2000
  3. Windows in case of other Windows versions
5. Enable and start the Windows Management Instrumentation service again.

For more details, refer the following links from Microsoft's official documentation:

                New to ADManager Plus?

                  New to ADSelfService Plus?

                    • Related Articles

                    • Configuring non-admin user account for WMI monitoring

                      QUESTION: How to set up WMI monitoring without domain admin or local admin credentials RESOLUTION: Windows will only allow members of the Administrators or Domain Admin groups to read WMI class information by default. However, you can configure a ...
                    • 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 ...
                    • Getting 'Invalid WMI query' with error code 0x80041017 in Windows

                      "Invalid WMI query" with error code WBEM_E_INVALID_QUERY (0x80041017) found in log files or script execution when collecting Windows performance counter data. It is possible that the Win32_PerfRawData_PerfOS_Processor cannot be found or accessed on ...
                    • Steps to verify WMI access for Non-Admin Domain user

                      This guide provides how to enable and test WMI access with a regular domain user without generic admin rights. Make sure you have followed the steps in the article Setting WMI access through Active Directory & Group Policy Object. This ensures you ...
                    • Basic WMI connection check when unable to add monitor

                      Follow the below steps to check the WMI connection when unable to add the monitor in WMI mode. Supported monitors: Active Directory, Microsoft Dynamics CRM / 356 On Prem, Microsoft Dynamics AX, Microsoft Skype for Business, Network Policy Server, ...