Accessing Registry Remote

by Feb 15, 2011

If you need to access registry keys and values on another machine, you can either use PowerShell Remote (requires PowerShell v2 on the remote machine), or you can use good old DCOM. Here is how:

# NOTE: RemoteRegistry Service needs to run on target system!
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', 'server123')
$key = $reg.OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall')

$key.GetSubKeyNames() | ForEach-Object {
$subkey = $key.OpenSubKey($_)
$i = @{}
$i.Name = $subkey.GetValue('DisplayName')
$i.Version = $subkey.GetValue('DisplayVersion')
New-Object PSObject -Property $i


Twitter This Tip!
ReTweet this Tip!