我正在尝试获取注册表项值,但我遇到了问题。
以下是我试图执行的命令。
Get-ChildItem "HKEY_LOCAL_MACHINE\SFTWARE\Wow6432Node\Mycompany\MyProj\Model" | ForEach-Object {Get-ItemProperty $_.pspath}
但是在附加了当前工作目录的注册表键路径中,会产生如下所示的意外问题。
PS C:\Users\Administrator\Desktop\MyDoc\Core\NodeRenameMaster> Get-ChildItem "HKEY_LOCAL_MACHINE\S
FTWARE\Wow6432Node\Mycompany\MyProj\Model" | ForEach-Object {Get-ItemProperty $_.pspath}
Get-ChildItem : Cannot find path 'C:\Users\Administrator\Desktop\MyDoc\Core\NodeRenameMaster\HKEY_
LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mycompany\MyProj\Model' because it does not exist.
At line:1 char:14
+ Get-ChildItem <<<< "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mycompany\MyProj\Model" | ForEach-Object {Get-Item
Property $_.pspath}
+ CategoryInfo : ObjectNotFound: (C:\Users\Admini...\Model:String) [Get-ChildItem], ItemNotFound
Exception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
为什么会这样?怎么解决这个问题?
答案 0 :(得分:2)
路径无效,将'HKEY_LOCAL_MACHINE'替换为'HKLM:\',将'SFTWARE'替换为'SOFTWARE'