wingetautoupdate/Sources/Winget-AutoUpdate/functions/Confirm-Installation.ps1

25 lines
647 B
PowerShell
Raw Normal View History

2023-12-06 00:42:38 +00:00
Function Confirm-Installation ($AppName, $AppVer) {
#Set json export file
2023-12-06 00:42:38 +00:00
$JsonFile = "$env:TEMP\InstalledApps.json"
#Get installed apps and version in json file
& $Winget export -s winget -o $JsonFile --include-versions | Out-Null
#Get json content
$Json = Get-Content $JsonFile -Raw | ConvertFrom-Json
#Get apps and version in hashtable
$Packages = $Json.Sources.Packages
# Search for specific app and version
2023-12-06 00:42:38 +00:00
$Apps = $Packages | Where-Object { $_.PackageIdentifier -eq $AppName -and $_.Version -like "$AppVer*" }
2023-12-06 00:42:38 +00:00
if ($Apps) {
return $true
}
2023-12-06 00:42:38 +00:00
else {
return $false
}
2024-09-02 14:10:21 +00:00
}