3

Is there an option to find installed software with the PowerShell? Mainly software is installed on a MSI basis. I tried it with the following code but I am not sure if it works reliable and for every software product. For example, 32- and 64-bit?

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | `
Select DisplayName, DisplayVersion, Publisher, InstallDate | sort {[string]$PSItem}

Is there a reliable way to find every installed software?

  • The contents of that registry key will be the same software you see under the control panel in 'Programs and Features', additionally there are Hotfixes and of course non MSI software. – beehaus Aug 10 '15 at 09:41
  • To be complete, the above would have to check both HKLM locations (32-bit and 64-bit) as well as HKCU. Of course that may not make a difference in practice on a given machine. – Michael Urman Aug 10 '15 at 11:54

3 Answers3

4

You can find all information about installed software, updates and hotfixes with the following PowerShell commands:

try{
    $InstalledSoftware = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
    $InstalledSoftware += Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
} catch {
    Write-warning "Error while trying to retreive installed software from inventory: $($_.Exception.Message)"
}

If I you want to find the installed MSI's, you could use the following:

$InstalledMSIs = @()
foreach ($App in $InstalledSoftware){
    if($App.PSChildname -match "\A\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}\z"){
        $InstalledMSIs += New-Object PSObject -Property @{
            DisplayName = $App.DisplayName;
            DisplayVersion = $App.DisplayVersion;
            Publisher = $App.Publisher;
            InstallDate = $App.InstallDate;
            GUID = $App.PSChildName;    
        }
    }
}

Also, you can check the installed Features on a Windows Server 2008 or higher OS with the following command:

Get-WindowsFeature -ErrorAction Stop | Where-Object {$_.Installed} | Sort-Object DisplayName
Johan de Haan
  • 1,010
  • 9
  • 13
  • Thanks for your addition. Now I get both 32- and 64-bit software. Additionally, is there a possibility to get the MSI product code out of the results as well? –  Aug 10 '15 at 11:36
  • 1
    The MSI product code is the name of the key directly under the Uninstall key. You can find this name by selecting PSChildname and match it with a regex `$InstalledSoftware[0].PSChildName -match "\A\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}\z"`. Shall I update my answer with an example? – Johan de Haan Aug 10 '15 at 11:52
  • Thanks for your quick response. An Example would be very nice! THX –  Aug 10 '15 at 11:58
  • Something like this..? – Johan de Haan Aug 10 '15 at 12:15
0

Surprisingly few people know about get-package. You can limit the output by programs or msi provider types. Uninstall-package works with msi installs. Otherwise you'll have to do something with $_.metadata['uninstallstring']. This stopped working in powershell 7.

get-package
js2010
  • 23,033
  • 6
  • 64
  • 66
-2

Below command will give you all the details about all the installed softwares (I believe this is more reliable).

Get-WmiObject -Class Win32_Product
SavindraSingh
  • 878
  • 13
  • 39
  • Thanks for this approach, The result looks definitely more beautiful than the approach with the regkeys, but there are some software products that are not displayed here. For example, I installed Foxit Reader and this software is only displayed when looking into the regkeys but unfortunately not with wmi ...Do you have any ideas why? –  Aug 10 '15 at 11:33
  • 1
    Win32_Product only shows Windows Installer (MSI) installations, so it is not good enough for Application Inventory. The uninstall registry-key in HKLM+HKCU Software\Microsoft AND Software\Wow6432Node\Microsoft is the best way AFAIK. – Frode F. Aug 10 '15 at 12:07
  • 2
    Win32_product is broken : querying this class will force a reregister (and sometimes a repair) on all registered MSI applications (that's why it's so slow). Check your application event logs after querying this class to see what I mean. – bluuf Aug 10 '15 at 19:34