In certain situations, we may need to check the list of installed software and its version and for this, we can make use of PowerShell.
Here at Bobcares, we have seen several such PowerShell related queries as part of our Server Management Services for web hosts and online service providers.
Use PowerShell to find list of installed software quickly
Today, we’ll take a look at how to get the list of all installed software using PowerShell.
PowerShell: Check installed software list locally
Now let’s see how our Support Engineers list the installed software locally.
Generally, we make use of Programs and Features in the Control Panel. Or browse all disk partitions in search of a specific app.
Checking the installed software versions by using PowerShell allows gathering data that we need much quicker.
1. Get installed software list with Get-WmiObject
In this method, we simply paste a simple query:
Get-WmiObject -Class Win32_Product
Also, we can filter the data to find specific applications from a single vendor, together with their versions, for example:
Get-WmiObject -Class Win32_Product | where vendor -eq CodeTwo | select Name, Version
This method is quite easy. But it has a downside that it takes quite a while to return the results.
2. Query registry for installed software
Another method is querying the registry to get the list of installed software. Here is a short script that returns the list of applications together with their versions:
$InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
foreach($obj in $InstalledSoftware){write-host $obj.GetValue('DisplayName') -NoNewline; write-host " - " -NoNewline; write-host $obj.GetValue('DisplayVersion')}
The above command will list all the software installed on the LM – local machine. However, applications can be installed per user as well. So, to return a list of applications of the currently logged user, we change HKLM to HKCU (CU stands for “current user”):
$InstalledSoftware = Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
foreach($obj in $InstalledSoftware){write-host $obj.GetValue('DisplayName') -NoNewline; write-host " - " -NoNewline; write-host $obj.GetValue('DisplayVersion')}
3. Getting the list of recently installed software from the Event Log
In order to check only the recently installed software, we use the following cmdlet to search through the Event Log.
Get-WinEvent -ProviderName msiinstaller | where id -eq 1033 | select timecreated,message | FL *
PowerShell: Get a list of installed software remotely
It is possible to remotely find the list of installed software on other machines. For that, we need to create a list of all the computer names in the network. Here are the different methods that we can use within a Foreach loop to return results from more than a single remote PC.
$pcname in each script stands for the name of the remote computer on which we want to get a list of installed software and their versions.
1. Get installed software list with remote Get-WmiObject command
The below cmdlet is the easiest one but can take some time to finish:
Get-WmiObject Win32_Product -ComputerName $pcname | select Name,Version
where $pcname is the name of the computer we want to query.
2. Check installed software with remote registry query
Remote registry queries are slightly more complicated and require the Remote Registry service to be running. A sample query is as follows:
$list=@()
$InstalledSoftwareKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
$InstalledSoftware=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$pcname)
$RegistryKey=$InstalledSoftware.OpenSubKey($InstalledSoftwareKey)
$SubKeys=$RegistryKey.GetSubKeyNames()
Foreach ($key in $SubKeys){
$thisKey=$InstalledSoftwareKey+"\\"+$key
$thisSubKey=$InstalledSoftware.OpenSubKey($thisKey)
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $pcname
$obj | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value $($thisSubKey.GetValue("DisplayName"))
$obj | Add-Member -MemberType NoteProperty -Name "DisplayVersion" -Value $($thisSubKey.GetValue("DisplayVersion"))
$list += $obj
}
$list | where { $_.DisplayName } | select ComputerName, DisplayName, DisplayVersion | FT
3. Check recently installed software list from the Event Log remotely
We can check a user’s event log remotely by adding a single attribute (-ComputerName) to the cmdlet used before:
Get-WinEvent -ComputerName $pcname -ProviderName msiinstaller | where id -eq 1033 | select timecreated,message | FL *
Check if a GPO-deployed software was applied successfully
If we apply a certain software version via GPO, then we can easily check if this GPO was successfully applied to a user or not. All we need is the GPResult tool and names of the target computer and user:
gpresult /s "PCNAME" /USER "Username" /h "Target location of the
HTML report"
Finally, we look for the GPO name and check if it is present under Applied GPOs or Denied GPOs.
[Need any further assistance with PowerShell queries? – We are here to help you.]
Conclusion
Today, we saw how our Support Engineers get the list of all installed software using PowerShell.
Nice one Gayathri, thanks
Hi,
I am looking for script which can be run on any server or desktop to know the number of Windows application installed on different VMware virtual desktop and servers.
Hi,
Please contact our support through live chat(click on the icon at right-bottom).
Never use “Get-WmiObject -Class Win32_Product” unless you want to update your resume
This causes software to re-initialize
Use “Get-Package” instead
This seems to work well, but it doesn’t appear to grab every application. For instance, when I run this I don’t see Firefox or Notepad++ listed. Are there limitations to this command?
Hi,
Please contact our support team through live chat (click on the icon at right-bottom).