Skip to content

Fixing Corrupt Wmi

Determine there is an issue

  1. Opening “System information” should yield a WMI error
  2. 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

  1. Check the repo

    Terminal window
    winmgmt /verifyrepository

    If the repository is not corrupted, a “WMI Repository is consistent” 

  2. Attempt salvage

    Terminal window
    winmgmt /salvagerepository
  3. Reset repo

    Terminal window
    winmgmt /resetrepository

Manually rebuild the repo

  1. Disable and stop the winmgmt service
  2. Remove or rename C:\Windows\System32\wbem\repository
  3. Enable and start the winmgmt service
  4. Open Command Prompt as Administrator
  5. Run the following commands:
    Terminal window
    cd C:\Windows\System32\wbem\
    for /f %s in ('dir /b *.mof') do mofcomp %s
    NOTE: This will take a minute or so to complete.
    for /f %s in ('dir /b en-us\*.mfl') do mofcomp en-us\%s
  6. Reboot
  7. 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.

Terminal window
mofcomp C:\Windows\system32\WindowsVirtualization.V2.mof
Mofcomp C:\Windows\system32\en-US\WindowsVirtualization.V2.mfl
Note

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