使用powershell在注册表项中获取特定字符串值的值

ar.*_*dll 2 registry powershell key

使用以下powershell脚本:

Get-ChildItem hkcu:\Test\Universe\Datawink\Switch1\Devices | ForEach-Object {Get-ItemProperty $_.pspath}
Run Code Online (Sandbox Code Playgroud)

我能够得到以下输出:

PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Test\Universe\Datawink\Switch1\Devices\Entry1
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Test\Universe\Datawink\Switch1\Devices
PSChildName  : Entry1
PSProvider   : Microsoft.PowerShell.Core\Registry
Device       : 2882881001
Recordable   : Yes
Active       : Yes

PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Test\Universe\Datawink\Switch1\Devices\Entry2
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Test\Universe\Datawink\Switch1\Devices
PSChildName  : Entry2
PSProvider   : Microsoft.PowerShell.Core\Registry
Device       : 2882881002

PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Test\Universe\Datawink\Switch1\Devices\Entry3
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Test\Universe\Datawink\Switch1\Devices
PSChildName  : Entry3
PSProvider   : Microsoft.PowerShell.Core\Registry
Device       : 2882881003
Run Code Online (Sandbox Code Playgroud)

哪个好,它向我显示了我想要的信息,但我真正需要的是名为'Device'的字符串条目的值,所以我真正想要的是脚本的输出如下所示:

Device       : 2882881001
Device       : 2882881002
Device       : 2882881003
Run Code Online (Sandbox Code Playgroud)

或理想情况下,这:

2882881001
2882881002
2882881003
Run Code Online (Sandbox Code Playgroud)

实现这一目标的最简单方法是什么?

Sha*_*evy 5

这也应该有效:

$path = 'hkcu:\Test\Universe\Datawink\Switch1\Devices'
Get-ChildItem $path | Get-ItemProperty | Select-Object -ExpandProperty Device
Run Code Online (Sandbox Code Playgroud)