Skip to content

Instantly share code, notes, and snippets.

@TylerJWhit
Last active December 7, 2019 16:02
Show Gist options
  • Save TylerJWhit/f596c307cf87540842281a8a20149f9a to your computer and use it in GitHub Desktop.
Save TylerJWhit/f596c307cf87540842281a8a20149f9a to your computer and use it in GitHub Desktop.
List all applications in Windows
# Version: 0.5
# Date: 2019-01-30
# File Name: Get-InstalledApps
# Author: TylerJWhit
# Notes:
# The following commands may be of help:
#
# Run against every computer in domain.
# Get-ADComputer -Filter * | Select-Object -ExpandProperty Name | Get-InstalledApps
#
# Run against CSV (replace path with location of file and ensure A1 says 'computername':
# Get-InstalledApps -computers (Import-Csv -Path C:\Computers.csv | Select-Object -ExpandProperty computername)
#
# Run against computers listed in command:
# Get-InstalledApps -computers HOSTNAMEA,HOSTNAMEB
function Get-InstalledApps {
Param (
[CmdletBinding()]
[Parameter(ValueFromPipeline=$true)]
[Alias('name')] # Helps with 'Select-Object -ExpandProperty Name'
[string[]]$computers = $env:COMPUTERNAME
)
process {
foreach($computer in $computers){
write-verbose -verbose -message "`nStarting scan on $computer"
Invoke-Command -Computername $computer -ErrorAction SilentlyContinue -ErrorVariable InvokeError -Scriptblock {
$installPaths = @('HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall','HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall')
Get-ChildItem -Path $installPaths | Get-ItemProperty | Sort-Object -Property DisplayName | Select-Object -Property DisplayName, DisplayVersion, Publisher, UninstallString, Version
}
if ($invokeerror){
Write-Warning "Could not communicate with $computer"
} # if ($invokeerror)
} # foreach($computer in $computers)
} # process
} # function Get-InstalledApps
@TylerJWhit
Copy link
Author

Last piece of the puzzle: missing the process bracket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment