Получение значения реестра с помощью WMI

Я получаю исключение, которое нигде не могу найти в документах. Вот исключение:

The following exception occurred while retrieving the type name hierarchy: "Not found".

$inParams также является нулевым. и вот код, который я использую:

$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()

Кто-нибудь знает, как это исправить?

Ответы на вопрос(2)

Ваш ответ на вопрос