Registry Key in Powershell

Registry Key in Powershell

Sometimes, for several reasons, you may have to manipulate registry key.

There ise the most know way to do that through the “regedit” command, and.. there is the way using Powershell !

Registry items, key, value, etc. are managed in Powershell as a file.

 

1. Create a registry key

To create a new registry key, just use the “New-Item” command and specify the path using, for example, “HKLM” For HKey_Local_Machine

New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\Key-To-Create'

To add a new property, same way, the command is “New-ItemProperty”. You will need also to specify the property name (-name) the value (-value) and the property type (-PropertyType) as shown below :

New-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Key-To-Create' -name PropertyName -value 0 -PropertyType 'DWord'

Source and more informations :

https://technet.microsoft.com/fr-fr/library/hh849795.aspx

https://technet.microsoft.com/fr-fr/library/hh849801.aspx

2.Modify a registry key value

Commands “Set-Item” and “Set-ItemProperty” can be use both to create/modify a registry key/value :

Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Key-To-Create' -name PropertyName -value 1

Source and more informations :

https://technet.microsoft.com/fr-fr/library/hh849844(v=wps.620).aspx

 

3. Delete a registry key

To Delete/Remove a new registry key, just use the “Remove-Item” command and specify the path using, for example, “HKLM” For HKey_Local_Machine

Remove-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\Key-To-Delete'

To remove a new property, same way, the command is “Remove-ItemProperty”. You will need also to specify the property name (-name) as below :

Remove-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Key-To-Delete' -name PropertyName

Source and more informations :

https://technet.microsoft.com/fr-fr/library/hh849765(v=wps.620).aspx

https://technet.microsoft.com/fr-fr/library/hh849770.aspx

Comments are closed.
How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site