27 lines
702 B
PowerShell
27 lines
702 B
PowerShell
Function Confirm-Installation ($AppName, $AppVer){
|
|
|
|
#Set json export file
|
|
$JsonFile = "$WorkingDir\Config\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
|
|
|
|
#Remove json file
|
|
Remove-Item $JsonFile -Force
|
|
|
|
# Search for specific app and version
|
|
$Apps = $Packages | Where-Object { $_.PackageIdentifier -eq $AppName -and $_.Version -eq $AppVer}
|
|
|
|
if ($Apps){
|
|
return $true
|
|
}
|
|
else{
|
|
return $false
|
|
}
|
|
} |