PoshCode Archive  Artifact [106e10cf1b]

Artifact 106e10cf1b84ee171f09642eec8180d415e5fe5f7b49d96372fc6b0feb202f11:

  • File Get-InstalledSoftware.ps1 — part of check-in [7e7f74ed46] at 2018-06-10 13:06:02 on branch trunk — From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes (user: Lee Holmes size: 1572)

# encoding: ascii
# api: powershell
# title: Get-InstalledSoftware.ps
# description: From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes
# version: 3.5
# author: Lee Holmes
# license: CC0
# x-poshcode-id: 2155
# x-archived: 2016-03-18T21:56:18
# x-published: 2011-09-09T21:41:00
#
#
##############################################################################
##
## Get-InstalledSoftware
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################

<#

.SYNOPSIS

Lists installed software on the current computer.

.EXAMPLE

Get-InstalledSoftware *Frame* | Select DisplayName

DisplayName
-----------
Microsoft .NET Framework 3.5 SP1
Microsoft .NET Framework 3.5 SP1
Hotfix for Microsoft .NET Framework 3.5 SP1 (KB953595)
Hotfix for Microsoft .NET Framework 3.5 SP1 (KB958484)
Update for Microsoft .NET Framework 3.5 SP1 (KB963707)

#>

param(
    ## The name of the software to search for
    $DisplayName = "*"
)

Set-StrictMode -Off

## Get all the listed software in the Uninstall key
$keys =
    Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

## Get all of the properties from those items
$items = $keys | Foreach-Object { Get-ItemProperty $_.PsPath }

## For each of those items, display the DisplayName and Publisher
foreach($item in $items)
{
    if(($item.DisplayName) -and ($item.DisplayName -like $displayName))
    {
        $item
    }
}