This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.



Retrieves specified keys, subkeys or values from the registry of a local or remote computer.


  • Get-Registrykey [-Key] [-ValueName] [-ComputerName] [-ShowFailures] [-Force32] [-Credential]


The Get-RegistryKey cmdlet is used to retrieve registry keys and values from a local or remote computer. By specifying a registry path in the Key parameter, Get-RegistryKey will return an object detailing the SubKeys and ValueNames found at that location. To retrieve a specific registry value, a value name may be appended to the registry path or optionally specified using the ValueName parameter. When specifying value names, Get-RegistryKey returns an object detailing the value of the specific value name only.


  • Key The key to return. Keys should be specified in the format HIVE:\SUBKEY, such as 'HKLM:\Software\Microsoft\Windows'. Valid registry hives are LocalMachine (HKLM:), CurrentUser (HKCU:), Users (HKU:) and ClassesRoot (HKCR:).
  • ValueName The specific value to return from the specified key.
  • ComputerName The computer against which to run the cmdlet. By default this parameter will be populated with the name of the local computer.
  • ShowFailures Output an error if key not found.
  • Force32 Force the use of WOW64 redirection. By default this cmdlet bypasses WOW64 redirection on 64-bit systems and accesses the Windows registry directly. Using this parameter forces the cmdlet to access the redirected 32-bit registry. When specified for use against 32-bit systems this parameter has no effect.
  • Credential The credentials under which to run the cmdlet. By default this cmdlet will run as the current user. Using this parameter and the Get-PSCredential cmdlet you can specify an alternate set of credentials under which to execute this command.


Get-RegistryKey accepts pipeline input only for the ComputerName parameter and requires that the input object contain a property named either Computer, CN or ComputerName.


Get-RegistryKey outputs a Vexasoft.RegistryKey object for a requested key or a .Net object of the appropriate type for a requested value.


By default, Get-RegistryKey bypasses WOW64 redirection when accessing 64-bit systems. This ensures consistent behaviour across systems regardless of Powershell host. To access 32-bit portions of the registry on 64-bit systems the -Force32 parameter can be used.

The Get-RegistryKey cmdlet requires that the RPC service is started on the computer it is trying to access and that DNS services are available to resolve target host names.

Example 1

This command will retrieve the PSPath value (in this case a string pointing to your local Powershell installation) stored at in the HKEY_LOCAL_MACHINE\Software\Vexasoft\CmdletLibrary key on the local computer:

C:\PS>Get-RegistryKey HKLM:\SOFTWARE\Vexasoft\CmdletLibrary -ValueName PSPath

Example 2

As with the previous example, this command will retrieve the PSPath value stored in the HKEY_LOCAL_MACHINE\Software\Vexasoft\CmdletLibrary key. Notice however that the ValueName has been appended to the Key path rather than specified as a separate parameter:

C:\PS>Get-RegistryKey HKLM:\SOFTWARE\Vexasoft\CmdletLibrary\PSPath

Example 3

As with the first example, this command will return the subkeys and values stored in the HKEY_LOCAL_MACHINE\Software\Vexasoft\CmdletLibrary key. However, because the -ShowFailures parameter is used, if the key is not found the cmdlet will throw an error. By default any error thrown will be non-terminating. Append the standard Powershell cmdlet parameter "-ErrorAction Stop" to treat the non-terminating errors thrown as terminating:

C:\PS>Get-RegistryKey HKLM:\SOFTWARE\Vexasoft\CmdletLibrary -ShowFailures