I would like to export multiple registry keys to the same .reg file. Every suggestion I've seen shows to use reg /e [key name] filename.reg, but I have a list of 4-5 registry entries I want to export and doing it this way will overwrite it each time. What I want is something like:
So that each registry key is appended to the same .reg file, not overwritten each time. How can I do this?
The simplest way would be to export each key individually, and then merge the resulting files:
$keys = 'HKLM\Software\Test\ABC', 'HKLM\Software\ABC\123', ...
$tempFolder = 'C:\temp\folder'
$outputFile = 'C:\path\to\merged.reg'
$keys | % {
$i++
& reg export $_ "$tempFolder\$i.reg"
}
'Windows Registry Editor Version 5.00' | Set-Content $outputFile
Get-Content "$tempFolder\*.reg" | ? {
$_ -ne 'Windows Registry Editor Version 5.00'
} | Add-Content $outputFile