title: Getting registry value using WMI
body: <p>I'm getting an exception which I can't find documented anywhere. Here is the exception:</p>
  
  <pre><code>The following exception occurred while retrieving the type name hierarchy: "Not found".
  </code></pre>
  
  <p>The <code>$inParams</code> is null as well.
  and here is the code I'm using:</p>
  
  <pre><code>$endpoint = "someEndpointName"
  $connectionOptions = New-Object 'System.Management.ConnectionOptions'
  
  $scope = New-Object 'System.Management.ManagementScope'("\\$endpoint\root\cimv2", $connectionOptions)
  $scope.Connect()
  
  $registry = New-Object 'System.Management.ManagementClass'($scope, (New-Object 'System.Management.ManagementPath'("StdRegProv")), $null) 
  $registrysType = $registry.GetType().Name
  #The line above throws this exception: "The following exception occurred while retrieving the type name hierarchy: "Not found".
  
  $inParams = $registry.GetMethodParameters("GetStringValue")
  $inParams["hDefKey"] = 2147483650 #this represents HKEY_LOCAL_MACHINE
  $inParams["sSubKeyName"] = "SOFTWARE\Company\EOS Version"
  $inParams["sValueName"] = "Build S Version"
  
  $outParams = $registry.InvokeMethod("GetStringValue", $inParams, $null)
  
  $buildSVersion = $outParams.Properties["sValueText"].Value.ToString()
  </code></pre>
  
  <p>Does anyone know how to fix this?</p>