循环中的Get-ItemProperty

时间:2018-04-23 14:18:08

标签: powershell

我有一个$arr = Get-ChildItem HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall 类型的集合示例:

$arr[3] | Get-ItemProperty | Where-Object {$_.DisplayName -like "MyProgram*"}

第3个元素包含我感兴趣的属性。我使用:

访问它
$arr | ForEach-Object { Get-ItemProperty $_ | Where-Object {$_.DisplayNAme -like "MyProgram*"}

这很好用。现在我试图循环收集(索引号未知):

$arr[3] | ...

返回错误:"找不到路径,因为它不存在"。

如何使用循环显示与{ "name": "@package_4effect/mypackage", "version": "0.0.3", "description": "Description for mypackage", "private": true, "license": "UNLICENSED", "cacheDirectories": [ "node_modules" ], "perDependencies": { ... "ng-packagr": "^2.0.0" }, "devDependencies": { ... }, "engines": { "node": ">=6.9.0" }, "scripts": { ..... "build": "yarn run webpack:prod", "build-pack": "ng-packagr -p package.json", } } 相同的输出?

我做错了什么?

1 个答案:

答案 0 :(得分:2)

您是否尝试过搜索?

Get-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
    Where-Object {$_.Displayname -like 'MyProgram*'}