Finding ALL installed applications with PowerShell?

14,850

Solution 1

Well, sorry to do this again. I had a bad habit of answering my own questions.

Anyway, I found the answer to my question by searching the registry for "CruiseControl.NET". It seems that 64bit versions of windows store Uninstall information in multiple places. Most notably, uninstall information seems to be primarily aggregated at the following key:

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

I was able to find every program on my system listed here, including CruiseControl.NET. Note that this only seems to be the case on 64bit Windows Systems.

Solution 2

I found this online it's magic, use in admin mode

Get-WMIObject Win32_InstalledWin32Program | select Name, Version, ProgramId

Solution 3

The below command finds CruiseControl.Net:

gci "HKLM:\software\Microsoft\windows\CurrentVersion\Uninstall" | %{ gp $_.PSPath } | where { $_.DisplayName -match "CruiseControl.NET" }

I can't honestly answer you about if the UninstallString is always present when searching the Uninstall Registry, nor can I tell you if you will find all applications installed on your machine. I know here MS gives instructions on a manual uninstall, which uses the UninstallString from this registry entry, so.. I am sure someone with more knowledge on the subject will comment..

Edit: Results on a Windows 7 Machine

PSPath            : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\Microsoft\windows\CurrentVersion\Uninstall\CruiseControl.NET
PSParentPath      : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\Microsoft\windows\CurrentVersion\Uninstall
PSChildName       : CruiseControl.NET
PSProvider        : Microsoft.PowerShell.Core\Registry
NSIS:StartMenuDir : CruiseControl.NET
CCNetVDir         : 1
DisplayName       : CruiseControl.NET 1.5.6804.1
UninstallString   : C:\Program Files\CruiseControl.NET\uninst.exe
DisplayIcon       : C:\Program Files\CruiseControl.NET\Server\ccnet.exe
DisplayVersion    : 1.5.6804.1
URLInfoAbout      : http://ccnet.thoughtworks.com/
Publisher         : ThoughtWorks
Share:
14,850
jrista
Author by

jrista

I am a C# Software Engineer and Architect, and have been developing on the .NET and Microsoft platform for most of my career. I am a huge fan of C#, I love DDD (Domain Driven Design), and am a fledgling advocate of BDD (Behavior Driven Development.) My favorite technical authors are Martin Fowler, Eric Evans, and Thomas Erl. See my .NET Configuration articles on CodeProject: Unraveling the Mysteries of .NET 2.0 Configuration Decoding the Mysteries of .NET 2.0 Configuration Cracking the Mysteries of .NET 2.0 Configuration

Updated on June 05, 2022

Comments

  • jrista
    jrista almost 2 years

    I am trying to use Windows PowerShell 2.0 to find an installed application. I have tried two methods, one using WMI and one using the Registry. Both methods are able to bring up a large list of installed applications and components, however neither one seems to bring up the application I am interested in.

    I am specifically looking for CruiseControl.NET. It appears in the list of applications in the Programs and Features control panel applet. I know for a fact that it is currently installed, since I just uninstalled and reinstalled it to start fresh. Neither of the following methods seem to work, however (they succeed, but return no results):

    Registry Search Approach

    Looks in the registry HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall for application keys. Returns plenty if I remove the where, but it is missing quite a few applications that do appear in the windows programs and features control panel.

    gci "hklm:\software\microsoft\windows\currentversion\uninstall" 
        | foreach { gp $_.PSPath } 
        | select DisplayVersion,InstallDate,ModifyPath,Publisher,UninstallString,Language,DisplayName 
        | where { $_.DisplayName -match "^Cruise*" }
    

    WMI Approach

    Also returns plenty, however, based on the documentation for the Win32_Product object, they are only MSI installed applications. Many applications are missing, I'm guessing because they are not MSI. The CruiseControl.NET installer is the NSIS (NullSoft Installation System)...since it doesn't appear here, I am guessing that it doesn't use MSI at all, however I am curious if there is another way to use WMI to find ANY/ALL installed applications, regardless of whether they used MSI or not.

    gwmi -namespace "root\cimv2" -class "Win32_Product" 
        | select Name,Vendor,Version,IdentifyingNumber 
        | where { $_.Name -match "^Cruise*" }
    

    Finding the application via the registry does not do me a whole lot of good, really. Unless it also provides some way to find the applications uninstaller and the correct parameters to invoke it, which does not appear to always be the case. I would prefer to use WMI to find and uninstall the applications I need to uninstall, as that would not only allow me to use a single management interface for all of my scripts (WMI), but it should be easy for others to figure out how to maintain the scripts in the future since WMI is generally well documented.

  • jrista
    jrista about 14 years
    I tried the above command, however it also returns nothing. I am using Windows 7, I am not sure if that plays a factor. For some reason, the version of CruiseControl.NET that I am installing refuses to show up anywhere but the Programs and Features control panel. There are also numerous other programs, such as VLC and Wireshark, that also do not appear in either the registry or wmi commands.
  • dugas
    dugas about 14 years
    @jrista - I edited the above post and pasted the results from the command on a Windows 7 machine. When you browse the registry with regedit do you see the entry?
  • jrista
    jrista about 14 years
    I actually don't see it in the registry. My Uninstall key in the registry contains a ton of guid keys, which mostly contain Microsoft stuff like Visual Studio, SQL Server, etc. Some Adobe things are in there as well. No sign of CruiseControl.NET however, but interestingly enough, it still shows up in the Programs/Features cpl. I can uninstall it from there as well, and it works. I'm just not sure where its getting the info from.
  • Tangiest
    Tangiest about 14 years
    jrista, answering your own questions is NOT a bad habit.