Edit Remote Registry Key PowerShell
Hello,
We previously saw how to read the registry remotely. We can use a very similar method to open a registry key with write access as I explain the comments.
The PowerShell code to use will be pretty similar as the read operation, but we will use an overload of RegistryKey.OpenSubKey:
This allow us to open a remote registry key and write to it:
$NewValue = '111' $Type = [Microsoft.Win32.RegistryValueKind]::String $ComputerName = 'DC2-Core' $Hive = [Microsoft.Win32.RegistryHive]::LocalMachine $KeyPath = 'SOFTWAREMicrosoftNotepadDefaultFonts' $Name = 'iPointSize' $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive, $ComputerName) $key = $reg.OpenSubKey($KeyPath, $true) $key.SetValue($Name,$NewValue,$Type)
And voilà, the remote registry key is modified. You can edit a few types of registry items like this, you just need to change the $Type:
You can also create new sub keys with the CreateSubKey method and its overload:
Name | Description | |
|
Creates a new subkey or opens an existing subkey for write access. | |
|
Creates a new subkey or opens an existing subkey with the specified access. | |
|
Creates a new subkey or opens an existing subkey with the specified access. | |
|
Creates a new subkey or opens an existing subkey for write access, using the specified permission check option. | |
|
Creates a subkey or opens a subkey for write access, using the specified permission check and registry options. | |
|
Creates a subkey or opens a subkey for write access, using the specified permission check option, registry option, and registry security. | |
|
Creates a new subkey or opens an existing subkey for write access, using the specified permission check option and registry security. |
Pingback: Change Office 365 Pro Plus Update Branch - It for DummiesIt for Dummies