Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View Tinus IT Wiki

View my Photo Website

List installed Software

published: February 14, 2019 author: Tinu tags: PowerShell categories: System-Engineering


Table of Contents

Get Software from WMI

Loop through the Win32_Product class and get all installed software.

$collection = Get-CimInstance -Class Win32_Product -ErrorAction SilentlyContinue | Where-Object {-not([string]::IsNullOrEmpty($_.Name))}

$resultset = foreach($item in $collection){
   # Add names and values to an PSCustomObject
   [PSCustomObject]@{
      InstallDate = $item.InstallDate
      Vendor      = $item.Vendor
      Name        = $item.Name
      PackageName = $item.PackageName
      Description = $item.Description
      Version     = $item.Version
   }
}
$resultset | Sort-Object Name | Format-Table -AutoSize

Output:

InstallDate Vendor                     Name                        Version
----------- ------                     ----                        -------
20180822    Adobe Systems Incorporated Adobe Acrobat Reader DC MUI 18.009.20044
20180918    Microsoft Corporation      PowerShell 6-x64            6.1.0.0

Get Software from Uninstallkey

Formats a hashtable to a PSCustomObject.

# 64-bit applications that run on a 64-bit version of Windows
$collection = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' `
| Get-ItemProperty | Where-Object {-not([string]::IsNullOrEmpty($_.DisplayName))} `
| Select-Object DisplayName,DisplayVersion,UninstallString

# 32-bit applications that run on a 64-bit version of Windows
$collection += Get-ChildItem 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall' `
| Get-ItemProperty | Where-Object {-not([string]::IsNullOrEmpty($_.DisplayName))} `
| Select-Object DisplayName,DisplayVersion,UninstallString

$resultset = foreach($item in $collection){
    [PSCustomObject] @{
        Name            = $item.DisplayName
        Version         = $item.DisplayVersion
        UninstallString = $item.UninstallString
    }
}
$resultset | Sort-Object Name | Format-Table -AutoSize

Output:

Name                                Version         UninstallString
----                                -------         ---------------
Adobe Acrobat Reader DC - Deutsch   19.010.20091    MsiExec.exe /I{AC76BA86-7AD7-1031-7B44-AC0F074E4100}
PowerShell 6-x64                    6.1.2.0         MsiExec.exe /X{65276649-728D-4AB9-AAEC-6EFF860B11EC}

← Previous Post [ Top ] Copyright © 2024 by tinuwalther [ Blog ] Next Post →