Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using powershell to change registry binary data

I understand that with powershell it's possible to change registry values.

for example, here: http://poshcode.org/3504

we can set the properties like this:

Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice' -name ProgId IE.FTP

however, is it possible to set these binary values using powershell??

enter image description here

like image 477
Alex Gordon Avatar asked Apr 09 '13 23:04

Alex Gordon


People also ask

How can I change binary code in registry?

On the Edit menu, point to New, and click Key; then, type the name of the subkey. Select the subkey under which you want to create a new value. On the Edit menu, point to New and then click String Value, Binary Value, or DWORD Value. Type the name of your new value.

Can you edit registry with PowerShell?

Using PowerShell, you can create, modify, or delete a registry key/parameters, search for the value, and connect to the registry on a remote computer. Contents: Navigate the Windows Registry Like a File System with PowerShell. Get a Registry Parameter Value via PowerShell.

Which PowerShell cmdlet is used to modify a registry key value?

You can also use the New-ItemProperty cmdlet to create the registry entry and its value and then use Set-ItemProperty to change the value. For more information about the HKLM: drive, type Get-Help Get-PSDrive . For more information about how to use PowerShell to manage the registry, type Get-Help Registry .


1 Answers

  1. Read the value (a byte array)
  2. Modify the array element
  3. Write the byte array back to the registry key.

Here's an example:

$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections'

$data = (Get-ItemProperty -Path $key -Name DefaultConnectionSettings).DefaultConnectionSettings
$data[8] = 9
Set-ItemProperty -Path $key -Name DefaultConnectionSettings -Value $data
like image 177
Andy Arismendi Avatar answered Sep 19 '22 16:09

Andy Arismendi