Skip to content

Instantly share code, notes, and snippets.

@w0ltage
Created October 7, 2022 02:15
Show Gist options
  • Save w0ltage/a00c716df9f1210c1ea9862aa5b6efc1 to your computer and use it in GitHub Desktop.
Save w0ltage/a00c716df9f1210c1ea9862aa5b6efc1 to your computer and use it in GitHub Desktop.
PowerShell - Check if the application is installed. If it is installed, write the name, vendor (publisher), version, and path to the file.
$software = Read-Host -Prompt 'Enter an application name: ';
$uninstallInfo = gp HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*
$applicationName = $uninstallInfo.DisplayName -Match $software
If ($applicationName) {
$anchor = [regex]::Match($uninstallInfo.PSPath -Match $software,'.*\\(.*)').captures.groups[1].value
$applicationInfo = gp HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$anchor
$vendor = $applicationInfo.Publisher
$version = $applicationInfo.DisplayVersion
$path = $applicationInfo.DisplayIcon
Write-Host "$applicationName is installed. Writing more info in .\$software.txt"
Out-File -File .\$software.txt -InputObject "'$applicationName' with verstion '$version' from '$vendor' is installed in '$path'"
} else {
Write-Host "'$software' NOT installed.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment