Find Installed Software

by Aug 31, 2017

Most installed software registers itself in one of four places inside the Windows Registry. Here is a quick PowerShell function called Get-InstalledSoftware that queries all of these keys, and outputs information about found software.

function Get-InstalledSoftware
{
    param
    (
        $DisplayName='*',

        $DisplayVersion='*',

        $UninstallString='*',

        $InstallDate='*'

    )
    
    # registry locations where installed software is logged
    $pathAllUser = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
    $pathCurrentUser = "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
    $pathAllUser32 = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    $pathCurrentUser32 = "Registry::HKEY_CURRENT_USER\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"

   
    # get all values
    Get-ItemProperty -Path $pathAllUser, $pathCurrentUser, $pathAllUser32, $pathCurrentUser32 |
      # choose the values to use
      Select-Object -Property DisplayVersion, DisplayName, UninstallString, InstallDate |
      # skip all values w/o displayname
      Where-Object DisplayName -ne $null |
      # apply user filters submitted via parameter:
      Where-Object DisplayName -like $DisplayName |
      Where-Object DisplayVersion -like $DisplayVersion |
      Where-Object UninstallString -like $UninstallString |
      Where-Object InstallDate -like $InstallDate |

      # sort by displayname
      Sort-Object -Property DisplayName 
}

The function also illustrates how you can use native registry paths without PowerShell drive letters by prepending the path with the provider name, in this case “Registry::”.

Also, the function exposes parameters for each outputted column (property), so the user can easily filter the results. Here is an example how you can find all software with “Microsoft” it its name:

 
PS C:\> Get-InstalledSoftware -DisplayName *Microsoft*

DisplayVersion DisplayName                                                           
-------------- -----------                                                           
               Definition Update for Microsoft Office 2013 (KB3115404) 32-Bit...
15.0.4569.1506 Microsoft Access MUI (English) 2013                                   
15.0.4569.1506 Microsoft Access Setup Metadata MUI (English) 2013                    
15.0.4569.1506 Microsoft DCF MUI (English) 2013                                      
15.0.4569.1506 Microsoft Excel MUI (English) 2013                                    
15.0.4569.1506 Microsoft Groove MUI (English) 2013
(...)
 

Twitter This Tip! ReTweet this Tip!