I was recently tasked with migrating a software which had all of it’s configuration stored in the registry. The only way to update it “officially” was by uninstalling and reinstalling the whole suite, since this would take too long for 30 machines, I decided to script it to quicken things up.

The way this works is by using the PowerShell functionality to search the registry –

foreach ($a in Get-ChildItem -Path ‘HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer’ -Recurse) {
  $a.Property | Where-Object {
    $a.GetValue($_) -Like “*value123*”
  } | ForEach-Object {
    $CurrentValue = $a.GetValue($_)
    $ReplacedValue = $CurrentValue.Replace(“value123", “value1234”)
    Write-Output “Changing value of $a\$_ from ‘$CurrentValue’ to ‘$ReplacedValue’”
    Set-ItemProperty -Path Registry::$a -Name $_ -Value $ReplacedValue
  }
}

The script explained –

i) It is searching in the Installer path with -Recurse, this means all the folder underneath it also.

ii) GetValue – This is going to first build the search index with any registry key containing value123. It will find values such as https://value123.domain.com or just value123 alone.

iii) ReplacedValue – We are giving it the value123 to identify and then replace it with value1234. It will not replace the whole string https://value123.domain.com, it will just replace it to https://value1234.domain.com

I hope this comes in handy for anyone searching to do something similar!