The Windows Management Instrumentation (WMI) service is a critical component of the Windows operating system, providing a way for administrators to monitor and manage various aspects of the system. However, sometimes issues can arise with WMI, such as repository corruption or a large repository size, which can cause problems with system performance and stability. In this article, we’ll walk through the steps to repair and rebuild the WMI repository on Windows Server.
Symptoms of WMI Repository Issues
There are several signs that the WMI repository may be corrupted or causing problems:
- Errors when running WMI queries, such as “WBEM_E_NOT_FOUND” or “WBEM_E_INVALID_CLASS”
- Slow performance of WMI queries
- Errors with Group Policy processing related to WMI filters
- Issues with SCCM/SCOM agent installation or operation
- Errors in scripts using the WMI namespace
Checking the WMI Repository for Consistency
The first step in troubleshooting WMI issues is to check the consistency of the WMI repository. You can do this by running the following command from an elevated command prompt:
winmgmt /verifyrepository
If the repository is consistent, you should see a message like “WMI Repository is consistent”. If the repository is inconsistent, you’ll see a message like “INCONSISTENT” or “WMI repository verification failed”.
Repairing the WMI Repository
If the WMI repository is found to be inconsistent, you can try repairing it using the following steps:
- Disable and stop the WMI service:
sc config winmgmt start= disabled
net stop winmgmt
- Run the following commands:
Winmgmt /salvagerepository %windir%\System32\wbem
- If the salvage operation fails, run
Winmgmt /resetrepository %windir%\System32\wbem
- Re-enable the WMI service and reboot the server:
sc config winmgmt start= auto
net start winmgmt
After rebooting, check to see if the WMI issues have been resolved. If not, you may need to rebuild the WMI repository manually.
Manually Rebuilding the WMI Repository
If the above steps don’t resolve the WMI issues, you can try manually rebuilding the WMI repository:
- Disable and stop the WMI service:
sc config winmgmt start= disabled
net stop winmgmt
- Rename the repository folder:
- Rename
%windir%\System32\wbem\Repository
to%windir%\System32\wbem\Repository.old
- Rename
- Re-register WMI DLLs:
cd %windir%\System32\wbem
for /f %s in ('dir /b *.dll') do regsvr32 /s %s
wmiprvse /regserver
- Re-enable the WMI service:
sc config winmgmt start= auto
net start winmgmt
- Recompile MOF files:
for /f %s in ('dir /s /b *.mof *.mfl') do mofcomp %s
- Reboot the server.
After rebooting, the WMI repository should be rebuilt and the issues should be resolved. If you continue to have problems, you may need to engage Microsoft Support for further assistance.
It’s important to note that rebuilding the WMI repository can sometimes cause issues with third-party applications that rely on WMI. In these cases, you may need to re-run the application’s setup and re-add any custom MOF files to the repository.
In conclusion, repairing and rebuilding the WMI repository is a common troubleshooting step for resolving issues with the WMI service on Windows Server. By following the steps outlined in this article, you should be able to get WMI back up and running smoothly.