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



Sets registry keys, subkeys and values on a local or remote computer.


  • Set-RegistryKey [-Key] [-ValueName] [-Value] [-ValueType] [-ComputerName] [-Force32] [-Credential] [-WhatIf] [-Confirm]
  • Set-RegistryKey [-Key] [-Values] [-ComputerName] [-Force32] [-Credential] [-WhatIf] [-Confirm]
  • Set-RegistryKey [-Key] [-CreateOnly] [-ComputerName] [-Force32] [-Credential] [-WhatIf] [-Confirm]


The Set-RegistryKey cmdlet is used to create or modify registry keys and values on a local or remote computer. When used in conjuction with the Get-RegistryKey cmdlet you can also copy registry keys from one computer to another (see the examples section below).

By default this cmdlet ignores SysWow redirection on 64-bit operating systems, writing directly to the 64-bit registry. This is to enable straightforward management of operating system settings from 32-bit PowerShell or remote 32-bit computers. This behaviour can be disabled using the Force32 parameter.

Registry values are automatically created as the correct registry type based on their value in PowerShell. Alternatively you can coerce the registry type using the ValueType parameter.


  • Key Make configuration changes to this key.
  • ValueName Add or modify this value name.
  • Value Write this value at the specified key under the specified value name. Existing values of the same name will be overwritten. The ValueName parameter must also be specified when using this parameter.
  • ValueType Add the specified value as this value type. Valid types are String, ExpandString, Binary, DWORD, QWORD or MultiString.
  • Values A hashtable of ValueNames and Values to create or modify at the specified key.
  • CreateOnly Create the key at the specified key location, but perform no other action.
  • ComputerName The computer against which to run the cmdlet. By default this parameter will be populated with the name of the local computer.
  • WOW64 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 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.


Set-RegistryKey accepts the output of Get-RegKey as an input object. In addition, the Key, ValueName, Value, ValueType, Values and ComputerName parameters each accept pipeline input by property name.


Set-RegistryKey makes changes directly to the Windows registry and does not output any Powershell objects.


By default, Set-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 -WOW64 parameter can be used.

The Set-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 set the 'Installer' value, under the 'HKEY_LOCAL_MACHINE\Software\MyCompany\MyProduct' key on the local computer to 'C:\MyProductInstall.exe'. If the 'Installer' value does not exist under the specified key, it is created. If the key itself does not exist, it too is created by the cmdlet:

Set-RegistryKey HKLM:\SOFTWARE\MyCompany\MyProduct -ValueName Installer -Value C:\MyProductInstall.exe

Example 2

Identical to the above cmdlet, but aimed at a remote computer, this command will set the 'Installer' value, under the 'HKEY_LOCAL_MACHINE\Software\MyCompany\MyProduct' key to 'C:\MyProductInstall.exe', on the remote computer PC01:

Set-RegistryKey 'HKLM:\SOFTWARE\MyCompany\MyProduct' -ValueName Installer -Value C:\MyProductInstall.exe -ComputerName PC01

Example 3

This command will set the 'IsInstalled' value, under the 'HKEY_LOCAL_MACHINE\Software\MyCompany\MyProduct' key on the local computer to the string value '1', as defined by the ValueType parameter. While it is usually not neccessary to specify a value type, in certain cases - such as here where you wish to store a number as a string instead of a DWORD - the ValueType parameter can be used to override the original type of the value when it is written to the registry:

Set-RegistryKey HKLM:\SOFTWARE\MyCompany\MyProduct -ValueName IsInstalled -Value 1 -ValueType String

Example 4

This command sets multiple values under the 'HKLM:\SOFTWARE\MyCompany\MyProduct' key, by specifying a hash table to the Values parameter:

Set-RegistryKey HKLM:\SOFTWARE\MyCompany\MyProduct -Values @{Installer="C:\MyProductInstall.exe";IsInstalled=1;IsRegistered="False"}

Example 5

This command, using the Get-RegistryKey and Set-RegistryKey cmdlets, gets the 'HKLM:\SOFTWARE\MyCompany\MyProduct' key and sets the 'IsInstalled' value to '0':

Get-RegistryKey HKLM:\SOFTWARE\MyCompany\MyProduct | Set-RegistryKey -ValueName IsInstalled -Value 0

Example 6

This command, using the Get-RegistryKey cmdlet in conjunction with Set-RegistryKey, gets the 'HKLM:\SOFTWARE\MyCompany\MyProduct' key and values from PC01 and recreates them on PC02:

Get-RegistryKey HKLM:\SOFTWARE\MyCompany\MyProduct -ComputerName PC01 | Set-RegistryKey -ComputerName PC02