InstalledApps.ps1

List the applications installed on one or more machines.
Call the script below passing the name of a text file containing the machines to query.
The output is written to a set of text files in the current directory, one per machine: Installed_Applications_<machine_name>.txt

Param($file)

function GetCompInfo{
    Param($srv)
    # Ping the machine to see if it is online
    $online=PingMachine $mc
    if ($online -eq $true)
    {
        Get-InstalledApps $srv |sort-object | out-file -filepath "Installed_Applications_$srv.txt"
    }
    else
    {
        Write-Verbose "     - Ping Failed!"
        Write-Host "Error: $srv not Pingable" -fore RED
    }
}

function Get-InstalledApps {
    Param([string]$server)
    Begin{
        function CheckRegKey{
            param([string]$srv)
            $key = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
            $type = [Microsoft.Win32.RegistryHive]::LocalMachine
            $regKey =[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv)
            $regKey = $regKey.OpenSubKey($key)
            foreach($sub in $regKey.GetSubKeyNames())
            {
                if($regKey.OpenSubKey($sub).GetValue("DisplayName"))
                {
                    $regKey.OpenSubKey($sub).GetValue("DisplayName")
                }
                else
                {
                    $sub
                }
            }
        }
        $process = @()
    }
    Process{
        if($_)
        {
            $process += $_
        }
    }
    End{
        if($Server)
        {
            $process += $Server
        }
        foreach($s in $process)
        {
            CheckRegKey $s
        }
    }
} 

function PingMachine {
   Param([string]$machinename)
   $pingresult = Get-WmiObject win32_pingstatus -f "address='$machinename'"
   if($pingresult.statuscode -eq 0) {$true} else {$false}
}

## Main

if($file -and (test-Path $file))
{
    foreach($comp in (get-Content $file))
    {
        Write-Host " +++ Processing Computer [$Comp] +++"
        GetCompInfo $comp
    }
}

Example

Call the script above passing the name of a text file containing the machines to query, one per line.
Assuming the script above is saved in the current directory as InstalledApps.ps1

PS C:\> ./installedapps workstations.txt

“In any collection of data, the figure most obviously correct, beyond all need of checking, is the mistake” ~ Finagle's Third Law

Related:

psinfo - List information about a system


© Copyright SS64.com 1999-2013
Some rights reserved