Reputation: 975
I have a collection of type Microsoft.Win32.RegistryKey
Example:
$arr = Get-ChildItem HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
The 3rd element contains the property I am interested in. I access it using:
$arr[3] | Get-ItemProperty | Where-Object {$_.DisplayName -like "MyProgram*"}
This works fine. Now I am trying to loop over the collection (index number is not known):
$arr | ForEach-Object { Get-ItemProperty $_ | Where-Object {$_.DisplayNAme -like "MyProgram*"}
Returns the error: "Cannot find path because it does not exist".
How can I display the same output as $arr[3] | ...
using a loop?
What am I doing wrong?
Upvotes: 0
Views: 1354
Reputation: 5252
Did you try to search for it?
Get-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
Where-Object {$_.Displayname -like 'MyProgram*'}
Upvotes: 2