PoshCode Archive  Artifact [d69dbbedd8]

Artifact d69dbbedd8d5021ec313afbf6758d6de5d6b6880abb9e357fb2c0216bf14c4f7:

  • File Get-InstalledSoftware.ps1 — part of check-in [84eb110249] at 2018-06-10 13:48:15 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: 4966
# x-archived: 2016-03-18T21:32:11
# x-published: 2016-03-08T09:19: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
    }
}