Testing for the presence of a remoteregistry key - using Win32 Registry provider

Looking for some suggestions - ‘best practice’ to test for the presence of a remote registry key without PS Remoting being available.

My environment has no PS Remoting, so I need to rely on using the old school method of connecting to the remote registry via -

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(“Users”, $computername)

The key is in this path $key="$SID\Software\Policies\Microsoft\office\14.0\outlook\options"

On a local machine I could do this in a few lines with New-PSDrive, test-path, get-childitem, but am challenged trying to wire this up for remote computers without the native PS Remoting. If the path is absent - I generate an error but am having difficulty working out an equivalent test-path type of code under the Microsoft.Win32.RegistryKey connection - any suggestions greatly appreciated

Does this help?


You mean, something like this…

$key = 'SYSTEM\CurrentControlSet\Control\Lsa'
$valuename = 'Security Packages'

Get-Content -Path 'e:\temp\Servers.txt' | 
ForEach-Object {
	$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $PSItem)
	$regkey = $reg.opensubkey($key)

Then there is always just use SysInternals PSExec to run stuff remotely.