Append Registry Key

Hi Experts

On few of my servers, i need to add registry entries remotely. Please guide me.

i have a registry entry by name exclude under (HKEY_LOCALMACHINE\SOFTWARE\MYAPPLICATION\CONFIG) and i need to add few entries like *.xyz , C:\xyz in the exclude registry.

I am trying to write powershell script experts help me

$Servers = Get-Content “C:\Servers.txt”
$TotalServersCount = ($Servers).Count
$PerCentageCounter = 1

Foreach ($Server IN $Servers) {
$PerCentCompleted = [System.Math]::Round(($PerCentageCounter/$TotalServersCount*100),0)

Write-Progress -Activity "Processing Server [$PerCentageCounter] [$Server]" -CurrentOperation "Checking Connectivity to the Server" 
# Check Ping Connection to the Server 
if (! (Test-Connection -ComputerName $Server -Count 2 -ErrorAction SilentlyContinue -Quiet)) {
    Write-Warning "Ping check failed for $Server, Skipping Server"
    Write-Progress -Activity "Ping check failed for $Server, Skipping Server" -Status "$PerCentCompleted% Complete:" -PercentComplete $PerCentCompleted
    Start-Sleep -Seconds 5

Write-Progress -Activity "Processing $Server Server" -CurrentOperation "Updating Registry Value" 
# Adding software exclusion

You posted a lot of code actually NOT doing what you want. My suggestion would be to focus on your actual task.

Does the the line


work as you expect it on a local machine? Did you test it?

You could start with this Use PowerShell to Easily Create New Registry Keys or that Update or Add Registry Key Value with PowerShell.
When this works for you as expected you could continue with that Running Remote Commands (Hint: see the paragraph Run a Remote Command)

A general hint for your “scripting career”: It is always very helpfull to always read the complete help for the commands you’re about to use - including examples. Really often you don’t need something else.

And last but not least - you could do youreself and us a favor: please use the code formatting option here in the forum. It much easier to read and to understand the code

I did not test it because i dont know how to proceed from here

under this config folder i have a string by name exclude , i need to add values to this exclude string like *.mdf …

So you should read the links I posted. They will help you. Test your code on an “unporductive” system - so you will not crash your real environment. :wink: