Accessing remote registry with #Powershell

That was a challenge. So I have a script that “pings” vcentre host to make sure they are working okay.

Part of the script connects to the registry and checks ODBC to get the SQL server that is used.

So normally this works:

$VCServer = “VCServer”
$key = “SOFTWAREODBCODBC.INIVMware VirtualCenter”
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $VCServer) $subregKey = $regKey.OpenSubKey($key)
$subregkey.GetValueNames()
$SQLServer = $subregkey.getValue(“Server”)

BUT, Mike is upgrading VCentre to the VSphere version and using a 64bit OS, but the machine that runs the script is 32bit. Here lies the problem, in that the new VCentre hides the ODBC information in a 64bit part of the registry that 32bit computers can’t access!

So after a lot of trial and error and using google I found this:

http://gallery.technet.microsoft.com/ScriptCenter/en-us/6062bbfc-53bf-4f92-994d-08f18c8324c0.

Its more code but works a dream and can get the 32bit registry keys too

Leave a Reply

%d bloggers like this: