Jump to page sections
List installed software on Windows with PowerShell
The lightweight method I'll use for listing installed software, is registry lookups. The "folders"/keys I'm looking at are HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall and HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall. This captures both 64-bit applications (the former registry key) and 32-bit applications on 64-bit Windows (the latter registry key).
The WMI class Win32_Product could be used, but as I recall, it triggers unwanted behavior even when you simply want to enumerate/list it, and it actually verifies the packages, and can even cause changes to a system simply from being enumerated, based on what I've read (it gets enumerated when you call Get-WmiObject -Class Win32_Product). I notice Win32_Product has the tag "legacy" on docs.microsoft.com. So we will not use this. There's more on Win32_Product in a blog article from 2011 on devblogs.microsoft.com here.
We will use a couple of simple, lightweight, CPU- and memory-friendly registry lookups with the flexibility of PowerShell's associated scripting language.
It is easy to add chocolatey packages as well, without the install date, so I did. You can omit that code if you want.
$Installed = @(Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate) $Installed += Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate $Installed = $Installed | Where-Object {$null -ne $_.DisplayName} | Sort-Object -Property DisplayName -Unique | ConvertTo-Csv -NoTypeInformation # Add chocolatey packages if the "choco" command is available. if (Get-Command -Name choco -ErrorAction SilentlyContinue) { $Installed += choco list -lo -r -y | ForEach-Object {'"' + $_.Replace("|", '","') + '","Chocolatey",""'} } $InstalledString = $Installed -join "`n" #Write-EventLog ... -Message $InstalledString # For instance captured in Splunk. #Write-Verbose -Verbose $InstalledString $Installed | Set-Content -LiteralPath .\installed_software.csv -Encoding UTF8
This is example code that assumes you want a CSV file. It can easily be altered to produce objects, should you need that (omit ConvertTo-Csv and handle choco output differently).
It might not capture all software, but it's likely the best one can generically do. You can add code to look for files and folders specific to your environment, if the software you use does not register itself properly. For instance using Test-Path.
Windows Powershell WMI Software Win32_Product RegistryBlog articles in alphabetical order
A
- A Look at the KLP AksjeNorden Index Mutual Fund
- A primitive hex version of the seq gnu utility, written in perl
- Accessing the Bing Search API v5 using PowerShell
- Accessing the Google Custom Search API using PowerShell
- Active directory password expiration notification
- Aksje-, fonds- og ETF-utbytterapportgenerator for Nordnet-transaksjonslogg
- Ascii art characters powershell script
- Automatically delete old IIS logs with PowerShell
C
- Calculate and enumerate subnets with PSipcalc
- Calculate the trend for financial products based on close rates
- Check for open TCP ports using PowerShell
- Check if an AD user exists with Get-ADUser
- Check when servers were last patched with Windows Update via COM or WSUS
- Compiling or packaging an executable from perl code on windows
- Convert between Windows and Unix epoch with Python and Perl
- Convert file encoding using linux and iconv
- Convert from most encodings to utf8 with powershell
- ConvertTo-Json for PowerShell version 2
- Create cryptographically secure and pseudorandom data with PowerShell
- Crypto is here - and it is not going away
- Crypto logo analysis ftw
D
G
- Get rid of Psychology in the Stock Markets
- Get Folder Size with PowerShell, Blazingly Fast
- Get Linux disk space report in PowerShell
- Get-Weather cmdlet for PowerShell, using the OpenWeatherMap API
- Get-wmiobject wrapper
- Getting computer information using powershell
- Getting computer models in a domain using Powershell
- Getting computer names from AD using Powershell
- Getting usernames from active directory with powershell
- Gnu seq on steroids with hex support and descending ranges
- Gullpriser hos Gullbanken mot spotprisen til gull
H
- Have PowerShell trigger an action when CPU or memory usage reaches certain values
- Historical view of the SnP 500 Index since 1927, when corona is rampant in mid-March 2020
- How to check perl module version
- How to list all AD computer object properties
- Hva det innebærer at særkravet for lån til sekundærbolig bortfaller
I
L
M
P
- Parse openssl certificate date output into .NET DateTime objects
- Parse PsLoggedOn.exe Output with PowerShell
- Parse schtasks.exe Output with PowerShell
- Perl on windows
- Port scan subnets with PSnmap for PowerShell
- PowerShell Relative Strength Index (RSI) Calculator
- PowerShell .NET regex to validate IPv6 address (RFC-compliant)
- PowerShell benchmarking module built around Measure-Command
- Powershell change the wmi timeout value
- PowerShell check if file exists
- Powershell check if folder exists
- PowerShell Cmdlet for Splitting an Array
- PowerShell Executables File System Locations
- PowerShell foreach loops and ForEach-Object
- PowerShell Get-MountPointData Cmdlet
- PowerShell Java Auto-Update Script
- Powershell multi-line comments
- Powershell prompt for password convert securestring to plain text
- Powershell psexec wrapper
- PowerShell regex to accurately match IPv4 address (0-255 only)
- Powershell regular expressions
- Powershell split operator
- Powershell vs perl at text processing
- PS2CMD - embed PowerShell code in a batch file
R
- Recursively Remove Empty Folders, using PowerShell
- Remote control mom via PowerShell and TeamViewer
- Remove empty elements from an array in PowerShell
- Remove first or last n characters from a string in PowerShell
- Rename unix utility - windows port
- Renaming files using PowerShell
- Running perl one-liners and scripts from powershell
S
- Sammenlign gullpriser og sølvpriser hos norske forhandlere av edelmetall
- Self-contained batch file with perl code
- Simple Morningstar Fund Report Script
- Sort a list of computers by domain first and then name, using PowerShell
- Sort strings with numbers more humanely in PowerShell
- Sorting in ascending and descending order simultaneously in PowerShell
- Spar en slant med en optimalisert kredittkortportefølje
- Spre finansiell risiko på en skattesmart måte med flere Aksjesparekontoer
- SSH from PowerShell using the SSH.NET library
- SSH-Sessions Add-on with SCP SFTP Support
- Static Mutual Fund Portfolio the Last 2 Years Up 43 Percent
- STOXR - Currency Conversion Software - Open Exchange Rates API