2023-09-15 14:38:54 +00:00
|
|
|
function Confirm-Installation
|
2023-09-15 14:33:51 +00:00
|
|
|
{
|
|
|
|
# Set json export file
|
|
|
|
|
|
|
|
[CmdletBinding()]
|
|
|
|
param
|
|
|
|
(
|
2023-09-15 14:38:54 +00:00
|
|
|
[string]
|
|
|
|
$AppName,
|
|
|
|
[string]
|
|
|
|
$AppVer
|
2023-09-15 14:33:51 +00:00
|
|
|
)
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
$JsonFile = ('{0}\Config\InstalledApps.json' -f $WorkingDir)
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
# Get installed apps and version in json file
|
|
|
|
$null = (& $Winget export -s winget -o $JsonFile --include-versions)
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
# Get json content
|
|
|
|
$Json = (Get-Content -Path $JsonFile -Raw | ConvertFrom-Json)
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
# Get apps and version in hashtable
|
|
|
|
$Packages = $Json.Sources.Packages
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
# Remove json file
|
|
|
|
$null = (Remove-Item -Path $JsonFile -Force -Confirm:$false -ErrorAction SilentlyContinue)
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
# Search for specific app and version
|
|
|
|
$Apps = $Packages | Where-Object -FilterScript {
|
|
|
|
($_.PackageIdentifier -eq $AppName -and $_.Version -like ('{0}*' -f $AppVer))
|
|
|
|
}
|
2023-09-15 14:38:54 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
if ($Apps)
|
|
|
|
{
|
|
|
|
return $true
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
}
|