I\'m getting an exception which I can\'t find documented anywhere. Here is the exception:
The following exception occurred while retrieving the type name hierarc
If you must use WMI use something like this (taken from the Scripting Guy blog):
$endpoint = 'someEndpointName'
$basekey = [uint32]'0x80000002'
$subkey = 'SOFTWARE\Company\EOS Version'
$value = 'Build S Version'
$reg = [wmiclass]"\\$endpoint\root\default:StdRegProv"
$buildSVersion = $reg.GetStringValue($basekey, $subkey, $value).sValue
Personally I'd prefer using remote registry access, though:
$endpoint = 'someEndpointName'
$basekey = 'LocalMachine'
$subkey = 'SOFTWARE\Company\EOS Version'
$value = 'Build S Version'
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($basekey, $endpoint)
$key = $reg.OpenSubKey($subkey, $true)
$buildSVersion = $key.GetValue($value)