Rebuilding the WMI Repository

You can rebuild the WMI repository (the database that stores meta-information and definitions for WMI classes) if it becomes corrupted.

Procedure

  1. Reboot the server.

  2. Check the WMI repository for consistency as follows:

    • For Windows 7, Windows Server 2008, and Windows Server 2008 R2, and Windows Vista and newer operating systems, run the following command from a command prompt: winmgmt/verifyrepository

    • For Windows XP and Windows Server 2003, run the following command from a command prompt: WmiDiag checkconsistency

  3. If the WMI repository is found to be consistent, run the following PowerShell commands to verify it:

    • PS C:> $query = “Select * from Win32_Bios”

    • PS C:> Get-WmiObject -Query $query

    If the above commands do not produce any output, the WMI repository is inconsistent. Proceed with Step 4, below, to fix it.

  4. If the WMI repository is found to be inconsistent for Windows 7, Windows Server 2008, and Windows Server 2008 R2, and Windows Vista and newer operating systems, do the following:

    1. From a command prompt with elevated privileges, run the following command: winmgmt/salvagerepository

      Note

      This command takes the content of the inconsistent WMI repository and merges it into the rebuilt repository if it is readable.

    2. If this doesn't work, run the following command from a command prompt: winmgmt/resetrepository

      Note

      This command resets the WMI repository to its initial state when the operating system was first installed.

    3. If this doesn't work, rebuild the WMI repository manually as described in Step 5, below.

  5. If the WMI repository is found to be inconsistent for Windows XP and Windows Server 2003, you must rebuild the WMI repository manually as described in Step 5, below.

  6. Rebuild the WMI repository manually as follows:

    Caution

    Rebuilding the WMI repository may result in some third-party products not working until their setup is re-run & their Microsoft Operations Framework re-added back to the repository.

    1. Change startup type to Window Management Instrumentation (WMI) Service to disabled.

    2. Stop the WMI Service.

      Note

      You may need to first stop IP Helper Service or other dependent services before the system allows you to stop the WMI Service.

    3. Rename the repository folder from C:\WINDOWS\system32\wbem\Repository to C:\WINDOWS\system32\wbem\Repository.old

    4. From a command prompt with elevated privileges, enter the following: cd c:\windows\system32\wbem

    5. For /f %s in ('dir /b /s *.dll') do regsvr32 /s %s

    6. Set the WMI Service type to Automatic and then start the WMI Service.

    7. From a command prompt with elevated privileges, enter the following: cd /d c:\

      Important

      You must go to the root of the c: drive.

    8. For /f %s in ('dir /s /b *.mof *.mfl') do mofcomp %s

    9. Reboot the server.

    10. Install the latest hotfixes for WMI, as they can help prevent further issues from occurring.

  7. If the WMI repository is found to be consistent, see Troubleshooting if WMI Repository is Found to be Consistent.

What to Do Next

If you continue to have recurring WMI repository corruption issues on the same server, contact a Microsoft Support Engineer for further troubleshooting and assistance.

Loading...