List Installed Applications

Here is a script you can use to check if a set of systems have some software installed, or list all applications installed on a set of servers.

Copy the below, paste in a .ps1 file. The instructions are in the script.

param([Parameter(Mandatory=$true)][String]$Path,[String]$filter)
#
# Original posting on how to access a remote Registry from The Powershell Guy 
# 
# http://thepowershellguy.com/blogs/posh/archive/2007/06/20/remote-registry-access-and-creating-new-registry-values-with-powershell.aspx 
# 
# This script will Query the Uninstall Key on a computer specified in $computername and list the applications installed there 
# $Branch contains the branch of the registry being accessed 
#  ' 
#
# Hereis where the differences start, the file is now a simple flat text file with the servers listed one at a time.
# I added two parameters;
#
# Path, This parameter is mandatory and takes the path to the list of servers.
# filter, This parameter lists the output to software containing the filter string.
#
# There are times when there will be no display name for the application, when this occurs, we output the key name preceeded by "--".
# The values are enclosed in brackets "[]" and the application name and the server are seperated by a comma. This should make it easy to load
# into excel.
#
# Usage: .\<script name> <-Path "path to server list> [-filter "*filter*"]

$COMPUTERS=gc $Path


FOREACH ($PC in $COMPUTERS) {

$computername=$PC

# Branch of the Registry 
$Branch='LocalMachine'

# Main Sub Branch you need to open 
$SubBranch="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"

$registry=[microsoft.win32.registrykey]::OpenRemoteBaseKey('Localmachine',$computername) 
$registrykey=$registry.OpenSubKey($Subbranch) 
$SubKeys=$registrykey.GetSubKeyNames()

# Drill through each key from the list and pull out the value of 
# “DisplayName” – Write to the Host console the name of the computer 
# with the application beside it

Foreach ($key in $subkeys) 
   { 
    $exactkey=$key 
    $NewSubKey=$SubBranch+"\\"+$exactkey 
    $ReadUninstall=$registry.OpenSubKey($NewSubKey) 
    $Value=$ReadUninstall.GetValue("DisplayName") 
 if([string]::IsNullOrEmpty($Value)){
    $Value = "--$exactkey"
    }
 if($Value -like "*$filter*" -or $filter -eq "ALL"){
       WRITE-HOST "[$Value], [$computername]"
    }
  } 
}

 

Leave a Reply