Windows: Troubleshooting WMI errors and repairing WMI
WMI Requirements
Windows Management Instrumentation (WMI) service is a requirement for the Nanitor agent on Windows.
WMI is a core part of Windows that allows programs to query information about the computer. Nanitor uses this to fetch various information such as operating systems, users, and more.
In some cases, the WMI service can stop working or the WMI repository can become corrupted and stop working properly. Possible reasons may be: - System upgrades - Running out of hard disk space - Memory or other hardware problems
The following instructions describe how to diagnose and repair WMI problems. Note that those problems cannot always be resolved, and one may need to reinstall Windows to remediate them. Furthermore, if WMI has been corrupted, there is a chance that other system files may have been corrupted. A reinstall may be the best option if more problems surface.
WMI Diagnostics
- First, we can check if the WMI Winmgmt service is running by running the following command as Administrator in PowerShell
Get-Service | findstr Winmgmt
PS C:\Users\Administrator> Get-Service | findstr Winmgmt
Running Winmgmt Windows Management Instrumentation
Start-Service Winmgmt
- To see if WMI is available and working, we can run a basic WMI query in PowerShell (as Administrator):
Get-WmiObject -query "SELECT * FROM Win32_OperatingSystem"
PS C:\Users\Administrator> Get-WmiObject -query "SELECT * FROM Win32_OperatingSystem"
SystemDirectory : C:\Windows\system32
Organization :
BuildNumber : 14393
RegisteredUser : Windows User
SerialNumber : 00377-90014-64864-AA792
Version : 10.0.14393
- Try rebooting the computer. That often fixes WMI problems, then recheck with steps 1-2. If that is not solved, then can proceed with the next step. 4. To check and validate the WMI repository, run:
winmgmt /verifyrepository
PS C:\Users\Administrator> winmgmt /verifyrepository
WMI repository is consistent
Repairing the WMI repository
Before attempting a repair, we need to first:
- Note that the repair might fail and the state on the machine could become worse. Some programs may not work as they used to before.
- You might end up needing to reinstall Windows on the device
-
Back up any important data and programs on the computer.
-
To attempt a consistency check, followed by a repair. Run in PowerShell (as Administrator).
winmgmt /salvagerepository
This performs a consistency check on the WMI repository, and if an inconsistency is detected, rebuilds the repository.
- Next check the consistency again:
winmgmt /verifyrepository
- Reboot the computer and check the WMI state as in the Diagnostics steps 1-4 above.
Proceed with caution and remember to back up any important data. 4. To reset the repository, run as Administrator:
winmgmt /resetrepository
You should see the message WMI Repository has been reset. If you see an error message instead, make a note of it.
5. Reboot the computer and re-run the verification steps (Diagnostics steps 1-4). Hopefully at this point everything is OK.
Otherwise, you may need to reinstall Windows on the computer or trying to do a system repair.