Tech Off Thread

7 posts

PowerShell: How to concat multiple Get-ItemProperty results into Out-GridView?

Back to Forum: Tech Off
  • User profile image
    androidi

    http://blogs.msdn.com/b/powershell/archive/2009/11/15/i-can-do-that-with-1-line-of-powershell-installed-software.aspx

    Ying Li has a cool PowerShell Script to list installed Software on a local computer HERE

    When I looked at it and thought to myself, I can do that with 1 line (if I cheat a little).  Here it is:

    PS> gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |Select DisplayName, DisplayVersion, Publisher, InstallDate, HelpLink, UninstallString |ogv

     

    HI Jeffrey. That's nice but you forgot there's atleast 2 other registry keys you need to list! How do you do that with one line so all the results are sortable in Out-GridView. I'd be very excited to learn this.

    HKCU SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
    HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
    HKLM SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

    (on one line without making a script file).

    My C# version.

    http://channel9.msdn.com/Forums/TechOff/how-to-PrintList-installed-programsapplications-sorted-by-date

  • User profile image
    wkempf

    You can treat the results as arrays, which means you can add them together. This produces a result, but you'd have to verify it's the correct result.

    21 ~> ((gp HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*) + (gp HKLM:\Software\Microsoft\Windows\CurrentVe rsion\Uninstall\*) + (gp HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*)) | Select DisplayName,  DisplayVersion, Publisher, InstallDate, HelpLink, UninstallString | ogv

    On my machine I get several blank entries, making me wonder if this is working correctly. If it is, I'd add a where filter to clean the results up.

  • User profile image
    AndyC

    Get-WmiObject -Class Win32_Product

    Smiley

  • User profile image
    wkempf

    , AndyC wrote

    Get-WmiObject -Class Win32_Product

    I get vastly different results using that (330 items with WMI and 937 items with the registry), and the WMI approach is much slower. Don't know how to account for the differences, but the WMI approach should be giving proper results.

  • User profile image
    androidi

    @wkempf:

    I haven't yet found a way to get exactly the results I get in Programs and Features.

    Get-WmiObject -Class Win32_Product doesn't list some of the programs that are listed in Programs and Features for example. I've read some installer put themself just into the Uninstall registry key and not into places where Win32_Product looks.

    I suspect closer results would be possible by adding some filtering to the registry key approach by using some of the values under the Uninstall key. It still does not answer the big question, where does Programs and Features get the InstallDate from? It has that date for apps which I can't find any date in the registry keys for. I tried checking the Uninstaller file dates, they can also be different than what's shown in Programs and Features. (win7 64)

  • User profile image
    erwindwight

    @androidi:

    Based on the documentation for the Win32_Product object, they are only MSI installed applications. Same with you, I was trying to filter the registries and it's working well for me actually. What I'm trying to do now is remove some identical software's in my output.

    Cheers!

  • User profile image
    AndyC

    @androidi:Raymond Chen has blogged about this in the past sometime, so searching his blog might help. From what I recall the Add/Remove Programs control panel uses heuristics to try and guess various bits of information such as the install date, size, etc if they aren't present in the registry (this is one of the reasons it takes so long to populate the list), so it could well be doing anything (searching for Start Menu shortcuts with a similar name is probably a good bet)

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.