Query Remote Registry for Key Value

# Open the specified Registry Hive on a remote machine specified. LocalMachine = HKLM / CurrentUser = HKCU
$computer = 'localhost'
$w32reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$computer)

# Open the specific registry key (exclude hive from path)
$keypath = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI'
$SubKey = $w32reg.OpenSubKey($keypath)

# Return data for a specific value
$SubKey.GetValue('LastLoggedOnUser')

# List all values
$SubKey.GetValueNames()

# Return data for all values to hashtable
$AllValues = @{}
$SubKey.GetValueNames() | ForEach-Object{
    $AllValues.Add($_,$SubKey.GetValue($_))
}
$AllValues
Details
This command will create a connection to a remote machine and return the specified registry values. It also shows how you can return all values and data for a key.