PowerShell script to edit remote registry

Did you ever wanted to modify your registry or add a key/value pair to registry? Wished there was a script to help you do that? Even better, wished it can run remotely without PowerShell WinRM listener configured on target server?

I had custom script that would modify certain registry entry but it was inflexible and in my recent rewrite of another script, I wanted more flexibility. So out of necessity, I decided to rewrite my registry script  and made it independent script with lot of flexibility.

Using this script, you can now run it like this:

.\Set-RemoteRegistry.ps1 -Key SYSTEM\CurrentControlSet\services\AudioSrv\Parameters -Name ServiceDllUnloadOnStop -Value 1 -Type DWord

If you want to suppress prompts, you can use –Force parameter like this:

.\Set-RemoteRegistry.ps1 -Key SYSTEM\CurrentControlSet\services\AudioSrv\Parameters -Name ServiceDllUnloadOnStop -Value 0 -Type DWord –Force

This script is also a good example of cmdletbinding and support of whatif. I still think use of Whatif in scripts has its limitations as apprarent in this script (without adding more code to it to work around that limitation).

The script is also a good example of how you can use parameter validation right in the parameter declaration. This way you can avoid if..then code blocks to validate parameter inputs. What a wonderful discovery, I gotta thank PowerShell team for this.

So go ahead, get the script Set-RemoteRegistry.ps1 here and if you find any issues, let me know. Have Fun!

Comments (2)
  1. Susan,

    The erros is because you are using incorrect syntax. You need to use the following syntax:

    .set-remoteregistry  -Key SOFTWAREWow6432NodeMicrosoftCCMCcmExec -name -provisioningmode -Value false -type string

    HLKM is hive and if you don't spoecify -hive, localmachine is used as default.

  2. susan says:


    Do you have any idea why I would get the following error from this script.  I just dont understand and I am new to POS as well as scripting.

    G:powershellSet-RemoteRegistry.ps1 : hklm:SOFTWAREWow6432NodeMicrosoftCCM doesn't exist. Exiting.

    At line:1 char:21

    the syntax I am using is

    .set-remoteregistry  -Key hklm:SOFTWAREWow6432NodeMicrosoftCCMCcmExec -name -provisioningmode -Value false -type string

    Im sure Im doing something stupid, but I would appreciate any help you might be able to offer.

Comments are closed.

Skip to main content