Powershell 递归复制注册表子树,其中某些子项名称包含斜杠
我在使用PowerShell复制注册表子树时遇到问题,因为某些键包含斜杠(例如Powershell 递归复制注册表子树,其中某些子项名称包含斜杠,powershell,registry,Powershell,Registry,我在使用PowerShell复制注册表子树时遇到问题,因为某些键包含斜杠(例如HKEY\U CURRENT\U USER\Software\Microsoft\VisualStudio\11.0\Languages\Language Services\C/C++) 如何递归复制这些子树?这是Powershell中的一个已知错误-它无法处理注册表路径中的正斜杠(适用于获取子项,因此我希望它也会影响复制项,重命名项,移动项等) 在最新的powershell(v4.0)中仍然存在 但是,您可以使用p
HKEY\U CURRENT\U USER\Software\Microsoft\VisualStudio\11.0\Languages\Language Services\C/C++
)
如何递归复制这些子树?这是Powershell中的一个已知错误-它无法处理注册表路径中的正斜杠(适用于
获取子项
,因此我希望它也会影响复制项
,重命名项
,移动项
等)
在最新的powershell(v4.0)中仍然存在
但是,您可以使用powershell运行Reg DOS命令:
我尝试了
-literalpath
,但它给出了相同的错误。遗憾的是,-whatif
对于注册表来说相当无用。它输出假设:在目标“项:HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Languages\Destination:HKEY_CURRENT_USER\ZZZ”上执行“复制密钥”操作。
然后打印关于“HKEY_CURRENT_USER\ZZZ”的两个错误不存在。我已更新了我的答案-似乎这是Powershell的一个已知问题,但尚未解决,其中注册表路径中有正斜杠。在Powershell 5.1中,该问题显然仍然存在。
PS > Copy-Item -recurse HKCU:\Software\Microsoft\VisualStudio\11.0\Languages HKCU:\ZZZ
Copy-Item : The registry key at the specified path does not exist.
At line:1 char:1
+ Copy-Item -recurse HKCU:\Software\Microsoft\VisualStudio\11.0\Languages HKCU:\So ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (HKEY_CURRENT_US...odeExpansions\C:String) [Copy-Item], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.CopyItemCommand
Copy-Item : The registry key at the specified path does not exist.
At line:1 char:1
+ Copy-Item -recurse HKCU:\Software\Microsoft\VisualStudio\11.0\Languages HKCU:\So ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (HKEY_CURRENT_US...uage Services\C:String) [Copy-Item], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.CopyItemCommand
reg.exe copy HKCU:\Software\Microsoft\VisualStudio\11.0\Languages HKCU:\ZZZ /s