How do I select a different PC when using HKEY_USERS?

You know that the content of HKEY_USERS depends on the currently logged on users on the targeted PC, don’t you?

Then why do I get different results when running the script from the explorer on PC1 than I get on PC2

How should I know that? :man_shrugging:t4: Again … I’m not a magician … I cannot see your screen and I cannot read your mind.

Probably there are not the same users logged on to the both PCs. And if they are they might have different printers connected.

This forum is not about Windows system support or Windows troubleshooting … it is about PowerShell. :wink:

If you are only after current user info … and don’t want to mess with WinRm, you could try playing with the following. This does require the Remote Registry service is enabled on the remote host and that you have admin on the remote system. Also, just a comment, if you have over 1000 systems, you should be able to get WinRM running on all of them using GPO. Google it.

<# Possible values for OpenRemoteBaseKey:
	ClassesRoot
	CurrentConfig
	CurrentUser
	LocalMachine
	PerformanceData
	Users
#>

$hostToCheck = 'SOMECOMPUTER'
$regPath = 'Printers\\Connections'
$objReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('CurrentUser', $hostToCheck)
$regKey = $objReg.OpenSubKey($regPath)
$regKey.GetValue('Name')


1 Like