Beems
Beems

Reputation: 810

Powershell to Parse/Iterate Through and Combine Two Registry Keys

Using PowerShell, I am looking to collect installed applications. This appears to be most-thoroughly accomplished by parsing the "Uninstall" section of the registry here:

HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\

AND

HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\

A simple PowerShell to parse the data and throw it in tabular format for just one of these could be:

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* 
| Select-Object DisplayName, DisplayVersion 
| Sort-Object DisplayName | Format-Table  -AutoSize

What I would like to do, instead of having to run the above line to get both x86 and x64 installed applications, would be to combine both into the same output. Is there simple solution to this that would allow the same line to parse both registry keys and combine the data into a single table?

Upvotes: 2

Views: 2850

Answers (1)

Kory Gill
Kory Gill

Reputation: 7153

See: Get-Help Get-ItemProperty and notice that Path is a string array

Get-ItemProperty [[-Path] <String[]>]

That means (like many commands) you can pass in multiple paths. For example:

Get-Itemproperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select DisplayName

From this, you can get all the rest of the answer you are looking for.

Upvotes: 6

Related Questions