Read Remote Registry PowerShell

Read Remote Registry PowerShell


You may used to read the registry of a remote computer with RegEdit.exe and “Connect Network Registry” (Require “Remote Registry service running on remote computer):

Read Remote Registry PowerShell - RegEdit

Read Remote Registry PowerShell – RegEdit

With PowerShell, there is a provider that allow us to browse the local registry just like a local drive :

Get-ItemProperty -Path HKLM:SOFTWAREMicrosoftNotepadDefaultFonts -Name iPointSize

Read Remote Registry PowerShell

If you want to read the registry from a remote computer, you can use “Invoke-Command”, this require you to setup PowerShell Remoting (Enable-PSRemoting) first:

Invoke-Command -ComputerName DC2-Core -Command {Get-ItemProperty -Path HKLM:SOFTWAREMicrosoftNotepadDefaultFonts -Name iPointSize}
Read Remote Registry PowerShell - Invoke-Command

Read Remote Registry PowerShell – Invoke-Command

If you can’t use PowerShell Remoting, you can use .Net to query a remote computer. To do that, you need use the “Microsoft.Win32.RegistryKey” .Net class.

First, prepare some variables for later use :

$ComputerName = 'DC2-Core'
$Hive = 'LocalMachine'
$KeyPath = 'SOFTWAREMicrosoftNotepadDefaultFonts'
$Value = 'iPointSize'

Then, create the RegistryKey object :

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("$hive", "$ComputerName")

Use the “OpenRemoteBaseKey” method :

$key = $reg.OpenSubKey("$KeyPath")

And finally, get the value :

Read Remote Registry PowerShell - PowerShell

Read Remote Registry PowerShell – PowerShell


So hereunder, all the lines together:

$ComputerName = 'DC2-Core'
$Hive = [Microsoft.Win32.RegistryHive]::LocalMachine
$KeyPath = 'SOFTWAREMicrosoftNotepadDefaultFonts'
$Value = 'iPointSize'

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive, $ComputerName)
$key = $reg.OpenSubKey($KeyPath)


You see the possible values of “Microsoft.Win32.RegistryHive” with IntelliSense or, with :

Read Remote Registry PowerShell - Hive


Edit Remote Registry PowerShell

As asked in the comments, I published a very basic example about how to edit remote registry:

The process is quite similar as reading, but you’ll notice that I used an Overload of the OpenSubKey method to tell I need to edit the subkey.

This example will work with PowerShell in version 2, without PowerShell Remoting enabled.

6 thoughts on “Read Remote Registry PowerShell

    • Just need to use the overload of OpenSubKey :
      The $true tells that you open the subkey with intent to edit it.

      • Thank you for being concise, just what I needed and the last comment about $True for editing was the final piece of the puzzle. All I needed to do was read a value and then delete it. (Remotely)

  1. Pingback: Get Windows Update Configuration PowerShell - It for DummiesIt for Dummies

  2. what kind of entitlements are needed for this? can a power user do this or is it administrator privileges only

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.