问题
I need to export registry keys from a remote computer for import into other remote machines (copy) using PowerShell V3.0.
When I use REG QUERY to view the registry keys thus:
reg query \\[computername]\HKLM\[subkey] /s | Out-File -append .\export.log
all subkeys are recursively output to export.log as expected.
However, when using REG SAVE to actually save a copy of the registry (in order to use REG RESTORE to import keys into target computers):
reg save \\[computername]\HKLM\[subkey] .\export.hiv
I am encountering the following error: "ERROR: The system was unable to find the specified registry key or value."
What's going on? Why can the REG QUERY find the specified keys/subkeys but not the REG SAVE?
The same issue presents when calling these commands from a Command Prompt..
回答1:
Here's what I did instead:
reg copy \\CopyFromPC\HKLM\SOFTWARE\ODBC \\CopyToPC\HKLM\SOFTWARE\ODBC /s /f
I don't think "reg save" allows the remote portion. See below
• Reg Query allows checking a remote PC:
PS C:\Windows> reg query /? KeyName [\Machine]FullKey Machine - Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines
• Reg Save doesn say it allows saving from remote PC:
PS C:\Windows> reg save /?
REG SAVE KeyName FileName [/y]
KeyName ROOTKEY\SubKey ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ] SubKey The full name of a registry key under the selected ROOTKEY.
FileName The name of the disk file to save. If no path is specified, the file is created in the current folder of the calling process.
/y Force overwriting the existing file without prompt.
Examples:
REG SAVE HKLM\Software\MyCo\MyApp AppBkUp.hiv Saves the hive MyApp to the file AppBkUp.hiv in the current folder
来源:https://stackoverflow.com/questions/24208793/attempting-to-export-remote-registry-hive-with-powershell