$SoftwareDisplayName = "Application Name" # wild cards are added to both sides automatically $Version = "1.1" # 1.2.3.004 $CompareMethod = "Ignore" # Ignore, Exact, SameOrHigher function VersionCompare() { param([System.Version]$version,[System.Version]$targetversion) if ($version -ge $targetversion) { return $true } else { return $false } } # 64-bit apps $software = Get-ItemProperty -Path "hklm:\software\microsoft\windows\currentversion\uninstall\*" -ErrorAction SilentlyContinue # 32-bit apps $software += Get-ItemProperty -Path "hklm:\software\wow6432node\microsoft\windows\currentversion\uninstall\*" -ErrorAction SilentlyContinue # Detect Software $search = ("*{0}*" -f $SoftwareDisplayName) $results = $software | Where-Object {$_.DisplayName -like $search} if($results) { # Package found, do version check based on compare method switch ($CompareMethod) { "Ignore" { Write-Output "detected" } "Exact" { if($results.DisplayVersion -eq $Version) { Write-Output "detected" } } "SameOrHigher" { if(VersionCompare -version $results.DisplayVersion -targetversion $Version) { Write-Output "detected" } } Default {} } }