Fixing Corrupt Wmi
Determine there is an issue
- Opening “System information” should yield a WMI error
- Opening WMI Control MMC snapin, right clicking the snapin then hitting “properties” should have an error ![[Pasted image 20260112074608.png|400]]
Solutions
Validating and run automatic fixes on the repo
-
Check the repo
Terminal window winmgmt /verifyrepositoryIf the repository is not corrupted, a “WMI Repository is consistent”
-
Attempt salvage
Terminal window winmgmt /salvagerepository -
Reset repo
Terminal window winmgmt /resetrepository
Manually rebuild the repo
- Disable and stop the winmgmt service
- Remove or rename C:\Windows\System32\wbem\repository
- Enable and start the winmgmt service
- Open Command Prompt as Administrator
- Run the following commands:
Terminal window cd C:\Windows\System32\wbem\for /f %s in ('dir /b *.mof') do mofcomp %sNOTE: This will take a minute or so to complete.for /f %s in ('dir /b en-us\*.mfl') do mofcomp en-us\%s - Reboot
- See section below, I believe this only adds in the default WMI components and specific add-ons (like HyperV) could be excluded from this rebuild.
Rebuilding specific WMI components
When I had to repair WMI it was because HyperV was broken, none of the VMs were up and I could not connect to the local machine despite the HyperV services being listed as running. The Spiceworks source contained these two commands which resolved the issue, I theorize if any other add-on components have WMI errors after manually rebuilding the repo you will have to do something akin to this.
mofcomp C:\Windows\system32\WindowsVirtualization.V2.mofMofcomp C:\Windows\system32\en-US\WindowsVirtualization.V2.mflNote
If I had to, I would try doing the for each commands from [[#Manually rebuild the repo]] but over the entire C:\Windows\System32 directory.
Sources:
- https://viettechgroup.vn/how-to-hyper-v-unable-to-connect-wmi-namespace-rootcimv2-to-localhost.html
- https://community.spiceworks.com/t/vms-missing-from-hyper-v-manager/553057