If your pc's are set up for WinRM you can run Invoke-Command against a list of pc names. I used c:\temp\pc.txt.
I don't have your problem so I tested with different keys. I have -whatif on the renames so you can run this against several pc's to find one that has the problem. Then remove the -whatif and test the script to verify that it does what you need.
$sb = {
"---------------------------------------------------------"
"Executing on {0}" -f $env:COMPUTERNAME
$Path = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
Get-ChildItem "Registry::$Path" | foreach {
"Looking at key {0}" -f $_.name
if ($_.name.EndsWith('.bak')) {
"Found a .bak !!!!!!!!!!!"
$Shortname = $_.PSChildName.Replace('.bak','') # Get the S-1-5-.......bak part and remove the .bak
"ShortName is {0}" -f $ShortName
$BadKey = $_.Name.Replace('.bak','') # Get HKEY_LOCAL_MACHINE\SOFTWARE.......bak part and remove the .bak
"BadKey is {0}" -f $BadKey
if (Test-Path "Registry::$BadKey") {
Get-item "Registry::$BadKey" | rename-item -NewName "$ShortName.temp" -whatif # rename with .temp
$_ | rename-item -NewName "$ShortName" -whatif # rename the .bak key we founf to remove the .bak
"Renamed!!!"
} else {
"I did not find the bad key. Nothing was updated."
}
}
}
}
$PCnames = get-content c:\temp\pc.txt # file containing list of pc names
foreach ($pc in $PCnames) {
Invoke-Command -ComputerName $pc -ScriptBlock $sb
}