Uncategorized · March 22, 2021 0

Change a registry value remotely with PowerShell

Welcome to Powermator,

today I will show you how you can change registry setting on a remote computer. In another word, how can you change a DWORD remotely.

Let me start with showing you what registry DWORD we want to change in our example.

as seen above:

Registry pathHKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters

and the value we will change is the

ValueAllowEncryptionOracle

so lets start the coding ; ) … at the beginning I will define three variables (remote computer name, registry path and value)

$computerName = "SomeName"
$registryPath = "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters\"
$name = "AllowEncryptionOracle"

we will need to use the invoke command and pass the path and value as parameters

Invoke-Command -ComputerName $computerName -ScriptBlock {
Param($registryPath ,$name)


} -ArgumentList $registryPath ,$name

so, lets read first the current value of the registry key; for that we will add the below command inside the invoke

Get-ItemProperty -Path $registryPath |% {$_.AllowEncryptionOracle}

so far I have tested the code and the output should looks like below

Last thing, use the New-ItemProperty instead of Get-ItemProperty to change the existing value and set whatever other value needed. In this case I will set it to 1.

New-ItemProperty -Path $registryPath -Name $name -Value "1" -PropertyType DWORD -Force | Out-Null

below is the code, feel free to use it on your own risk for reading or editing a registry value

cls
$computerName = "SomeName"
$registryPath = "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters\"
$name = "AllowEncryptionOracle"

Invoke-Command -ComputerName $computerName -ScriptBlock {
Param($registryPath ,$name)
} -ArgumentList $registryPath ,$name

Get-ItemProperty -Path $registryPath |% {$_.AllowEncryptionOracle}
# New-ItemProperty -Path $registryPath -Name $name -Value "1" -PropertyType DWORD -Force | Out-Null
} -ArgumentList $registryPath ,$name

remember; you need to have admin rights to change registry values other wise you will get an error

Thats it.

Happy coding

Jaber

Close Bitnami banner
Bitnami