Attempting to export remote registry hive with PowerShell

天大地大妈咪最大 提交于 2019-12-10 11:41:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!