PowerShell, Get a List of Installed Applications

Don't Do...

Do you need to get a list of installed applications from a computer don't use Win32_Product, and here is why:

"The Win32_product class is not query optimized. Queries such as “select * from Win32_Product where (name like ‘Sniffer%’)” require WMI to use the MSI provider to enumerate all of the installed products and then parse the full list sequentially to handle the “where” clause:,

  • This process initiates a consistency check of packages installed, and then verifying and repairing the installations.
  • If you have an application that makes use of the Win32_Product class, you should contact the vendor to get an updated version that does not use this class.

On Windows Server 2003, Windows Vista, and newer operating systems, querying Win32_Product will trigger Windows Installer to perform a consistency check to verify the health of the application. This consistency check could cause a repair installation to occur. You can confirm this by checking the Windows Application Event log. You will see the following events each time the class is queried and for each product installed"

Use PowerShell to Quickly Find Installed Software | Scripting Blog
Summary: Learn how to use Windows PowerShell to quickly find installed software on local and remote computers. Microsoft Scripting Guy Ed Wilson here. Guest Blogger Weekend concludes with Marc Carter. The Scripting Wife and I were lucky enough to attend the first PowerShell User Group meeting in C…
Reference

Do This...

function Get-InstalledApplications {
<#
.SYNOPSIS
    Gets a list of installed programs.

.DESCRIPTION
    Gets a list of installed programs from the HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ and HKLM:\Software\Wow6432Node\Windows\CurrentVersion\Uninstall.

.PARAMETER NONE

.EXAMPLE
    .\Get-InstalledApplications

#>	
    if([IntPtr]::Size -eq 4) {
        $regpath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
    } else {
        $regpath = @(
            'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
            'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
        )
    }
    Get-ItemProperty $regpath | . { process { if ($_.DisplayName -and $_.UninstallString) { $_ } } } | Select-Object DisplayName, Publisher, InstallDate, InstallLocation, DisplayVersion, UninstallString | Sort-Object DisplayName
}