Monthly Archive


Testing the WMI repository

Occasionally the WMI database becomes corrupt. Strangely I have seen this happening more often recently because of the creation of virtual machines from templates – if the template is corrupt so will be the virtual machines.

With Windows Vista and above we can use the winmgmt utility to test the repository. I’ve gotten used to the verb-noun syntax of PowerShell so decided to create a wrapper rather than try and remember the syntax

function test-wmirepository {            
 if ($path) {            
   if (-not(Test-Path $path)){            
    Throw "$path not found"            
   else {            
    $exp = "winmgmt /verifyrepository $path"            
 else {            
  $exp = "winmgmt /verifyrepository"            
 Invoke-Expression -Command $exp            


The utility can test the repository (default) or if the path to a backup file is given then that can be tested instead.

PS> test-wmirepository

WMI repository is consistent

if you don’t get the message about the repository being consistent then you have a problem. We’ll see how to fix that later.

How do you take a backup of the repository? – We’ll get to that later as well

Leave a Reply