JohnKlann / Posts tagged "poweshell"

How to get and set a registry key using powershell

Hi Just a quick blurb on how to get and set registry values with powershell:

  1. Command Syntax:
    Set-ItemProperty -Path "Hive:KeyPath" -Name "DWORD or what not to change" -Value "value to set it to"
  2. Example to Set the Cygwin root directory:
    Set-ItemProperty -Path "HKLM:\SOFTWARE\Cygwin\setup" -Name "rootdir" -Value "c:\dev\cyg"
  3. Example to Get the Cygwin root directory:
    Get-ItemProperty -Path "HKLM:\SOFTWARE\Cygwin\setup" -Name "rootdir" | %{$_.rootdir}
  4. Output: