Skip to content

Instantly share code, notes, and snippets.

@eplord
Forked from indented-automation/Find-Software.ps1
Last active August 1, 2025 07:21
Show Gist options
  • Select an option

  • Save eplord/ba1c4630bde783f3000e05e8be732751 to your computer and use it in GitHub Desktop.

Select an option

Save eplord/ba1c4630bde783f3000e05e8be732751 to your computer and use it in GitHub Desktop.

README.md

PowerShell Script to Find Software

#=====================================

This script will find software installed on a Windows system using PowerShell.

It can be used to check for specific software like Chrome or Firefox.

Usage

1. Save this script as a .ps1 file (e.g., FindSoftware.ps

2. Open PowerShell as Administrator.

3. Run the script using the command: .\FindSoftware.ps1

4. The script will output a list of installed software.

#=====================================

function Get-GistURL { param ( [string]$GistID ) return "https://gist.githubusercontent.com/$GistID/raw/Find-Software.ps1" }

function Load-FindSoftware { $gistID = "ba1c4630bde783f3000e05e8be732751" $scriptContent = Invoke-WebRequest -Uri (Get-GistURL -GistID $gistID) -UseBasicParsing Invoke-Expression $scriptContent.Content }

function PipeTo-Json { param ( [Parameter(Mandatory = $true)] [object]$InputObject ) return $InputObject | ConvertTo-Json -Depth 10 }

Load-FindSoftware

function Find-Software { param ( [string[]]$SoftwareNames, [switch]$EnableNetworkAccess )

$DefaultHttpHeaders = @{
    "User-Agent" = "PowerShell/$(Get-Host).Version"
}

if ($EnableNetworkAccess) {
    $DefaultHttpHeaders["Accept"] = "application/json"
}

$data = @{
    SoftwareNames = $SoftwareNames
    EnableNetworkAccess = $EnableNetworkAccess.IsPresent
}

# Convert the data to JSON format
$jsonData = PipeTo-Json -InputObject $data

# Send the request to the API endpoint
$response = Invoke-WebRequest -Uri "https://api.example.com/software" -Method Post `
    -Body $jsonData `
    -ContentType "application/json" `
    -Headers $DefaultHttpHeaders
    \end{code}

try { Invoke-RestMethod "https://api.mysite.com/the/endpoint" -Body (ConvertTo-Json $data) -ContentType "application/json" -Headers $DefaultHttpHeaders -Method Post } catch { $streamReader = [System.IO.StreamReader]::new($_.Exception.Response.GetResponseStream()) $ErrResp = $streamReader.ReadToEnd() | ConvertFrom-Json $streamReader.Close() }

function Find-Software {
[CmdletBinding()]
param (
<#
The name, or part of a name, of a package.
Should be enough to get a unique match or the results will get really messy.
#>
[Parameter(Mandatory)]
[Alias('Name')]
[string[]]
$PackageName,
<#
One or more computer names.
#>
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[string[]]
$ComputerName = $env:COMPUTERNAME,
<#
See Get-Help Invoke-Command.
#>
[Parameter()]
[int]
$ThrottleLimit,
<#
See Get-Help New-PSSessionOption.
#>
[Parameter()]
[Timespan]
$OpenTimeout,
<#
See Get-Help New-PSSessionOption.
#>
[Parameter()]
[Timespan]
$OperationTimeout,
<#
See Get-Help Invoke-Command.
#>
[Parameter()]
[switch]
$EnableNetworkAccess
)
begin {
$allComputers = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
}
process {
foreach ($name in $ComputerName) {
$null = $allComputers.Add($name)
}
}
end {
$invokeSplat = @{
ComputerName = $allComputers
HideComputerName = $true
}
if ($ThrottleLimit) {
$invokeSplat['ThrottleLimit'] = $ThrottleLimit
}
if ($EnableNetworkAccess) {
$invokeSplat['EnableNetworkAccess'] = $true
}
$optionSplat = @{}
if ($OpenTimeout) {
$optionSplat['OpenTimeout'] = $OpenTimeout
}
if ($OperationTimeout) {
$optionSplat['OperationTimeout'] = $OperationTimeout
}
if ($splat.Count) {
$invokeSplat['SessionOption'] = New-PSSessionOption @optionSplat
}
$namePattern = $PackageName.ForEach{ [Regex]::Escape($_) } -join '|'
Invoke-Command @invokeSplat -ScriptBlock {
$output = [Ordered]@{
ComputerName = $env:COMPUTERNAME
}
foreach ($name in $using:PackageName) {
$output[$name] = 'Not detected'
}
Get-ItemProperty -Path @(
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
) | Where-Object DisplayName -match $using:namePattern | ForEach-Object {
$output[$matches[0]] = $_.DisplayVersion
}
[PSCustomObject]$output
} | Select-Object * -ExcludeProperty RunspaceId
}
}
Find-Software chrome, firefox -EnableNetworkAccess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment