PowerShell 27 Finding Installed Programs through the Registry

Published: 15 December 2022
on channel: Kilts and Computers
558
14

In this video, the Kilt Guy shows you how to collect and information for installed programs from the Registry using a PowerShell script

Commands used in the shell:
Get-WmiObject
Where-Object
Select-Object
Sort-Object
Add-Member

No chapters this time around, but I do have the full script for you, with some additional comments not shown in the video.

========================
#Create an instance of the Registry Object and open the HKLM base key
$reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$env:computername)

#Define the variable to hold the location of Currently Installed Programs
$UninstallKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"

#Drill down into the Uninstall key using the OpenSubKey Method
$regkey=$reg.OpenSubKey($UninstallKey)

#Retrieve an array of strings which contain all the subkey names
$subkeys=$regkey.GetSubKeyNames()

#Open each Subkey and use GetValue Method to return the required values for each
$InstalledPrograms = @()
foreach($key in $subkeys){
$thisKey=$UninstallKey+"\\"+$key
$thisSubKey=$reg.OpenSubKey($thisKey)
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "Caption" -Value $($thisSubKey.GetValue("DisplayName"))
$obj | Add-Member -MemberType NoteProperty -Name "Version" -Value $($thisSubKey.GetValue("DisplayVersion"))
$obj | Add-Member -MemberType NoteProperty -Name "InstallDate" -Value $($thisSubKey.GetValue("InstallDate"))
$obj | Add-Member -MemberType NoteProperty -Name "InstallLocation" -Value $($thisSubKey.GetValue("InstallLocation"))
$obj | Add-Member -MemberType NoteProperty -Name "InstallSource" -Value $($thisSubKey.GetValue("InstallSource"))
$obj | Add-Member -MemberType NoteProperty -Name "Publisher" -Value $($thisSubKey.GetValue("Publisher"))
$InstalledPrograms += $obj
}
$InstalledPrograms | Where-Object { $_.Caption } | Select-Object Caption, Version, InstallDate, InstallLocation, InstallSource |
Sort-Object -Descending InstallDate | Format-Table -auto

========================


On this page of the site you can watch the video online PowerShell 27 Finding Installed Programs through the Registry with a duration of hours minute second in good quality, which was uploaded by the user Kilts and Computers 15 December 2022, share the link with friends and acquaintances, this video has already been watched 558 times on youtube and it was liked by 14 viewers. Enjoy your viewing!