How to Use PowerShell to Quickly Find Installed Software









Sometimes, we may need to check the list of installed software and its version and for this, we can make use of PowerShell.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform PowerShell related queries.

In this context, we shall look into how to get the list of all installed software using PowerShell.


How to Check installed software list locally using PowerShell ?

Here, you will see how to 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. 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

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 *

 

How to Get a list of installed software remotely with PowerShell?

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.


i. 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.


ii. 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 urgent assistance with PowerShell queries? – We are here to help you.]

Conclusion

This article will guide you on how to get the list of all installed #software using #PowerShell. 

i. First, open PowerShell by clicking on the Start menu and typing “powershell”. 

ii. Select the first option that comes up and you'll be greeted with an empty PowerShell #prompt. 

iii. PowerShell will give you a list of all your #programs, complete with the version, name of the developer, and even the date you installed it.