Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t通过Powershell从Regedit中拉出信息_Powershell - Fatal编程技术网

Can';t通过Powershell从Regedit中拉出信息

Can';t通过Powershell从Regedit中拉出信息,powershell,Powershell,我无法使此代码正常工作: Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object{Get-ItemProperty$.pspath} 其中对象{$.DisplayName-Eq'Microsoft Lync 2013'}选择对象显示版本 我做错了什么 这一个很好用,它们都在regedit中,我知道这个示例不是en-wow6432node,这可能是问题所在吗 Get-Child

我无法使此代码正常工作:

Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object{Get-ItemProperty$.pspath} 其中对象{$.DisplayName-Eq'Microsoft Lync 2013'}选择对象显示版本

我做错了什么

这一个很好用,它们都在regedit中,我知道这个示例不是en-wow6432node,这可能是问题所在吗

Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach对象{Get-ItemProperty$.pspath} 其中对象{$.DisplayName-Eq‘Microsoft安全客户端’}选择对象显示版本


您有几个语法错误。在这种情况下,我尝试将一行代码分解为多个步骤,并编写一个
.ps1
文件来发现错误。将此文件复制到您选择的文件中:

$a = Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall 
$b = $a | ForEach-Object {  Get-ItemProperty $_.pspath} 
$c = $b | Where-Object { $_.DisplayName -Eq 'Microsoft Lync 2013'} 
$d = $c | Select-Object DisplayVersion

write-host `$d.length  $d.length
write-host content of `$d 
$d

write-host 
write-host intermediate results were:
write-host `$c.length  $c.length
write-host `$b.length  $b.length
write-host `$a.length  $a.length  

pause
在我的案例中,在步骤$c之后,我没有得到任何结果,因为我没有安装Microsoft Lync 2013:

PS> .\test.ps1
$d.length 0
content of $d

intermediate results were:
$c.length 0
$b.length 976
$a.length 992
Drücken Sie die Eingabetaste, um den Vorgang fortzusetzen...: