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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: