Merge pull request #356 from Romanitho/install-detection-review

Improved application detection after upgrade
pull/359/head
Romain 2023-06-21 17:30:21 +02:00 committed by GitHub
commit 06fa1b0ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 35 deletions

View File

@ -0,0 +1,27 @@
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
}
}

View File

@ -5,6 +5,9 @@ function Start-Init {
#Config console output encoding
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# Workaround for ARM64 (Access Denied / Win32 internal Server error)
$Script:ProgressPreference = 'SilentlyContinue'
$caller = Get-ChildItem $MyInvocation.PSCommandPath | Select-Object -Expand Name
if ($caller -eq "Winget-Upgrade.ps1") {
#Log Header

View File

@ -5,9 +5,6 @@ function Test-Network {
#Init
$timeout = 0
# Workaround for ARM64 (Access Denied / Win32 internal Server error)
$ProgressPreference = 'SilentlyContinue'
#Test connectivity during 30 min then timeout
Write-ToLog "Checking internet connection..." "Yellow"
While ($timeout -lt 1800) {

View File

@ -44,11 +44,10 @@ Function Update-App ($app) {
}
#Check if application updated properly
$CheckOutdated = Get-WingetOutdatedApps
$FailedToUpgrade = $false
foreach ($CheckApp in $CheckOutdated) {
if ($($CheckApp.Id) -eq $($app.Id)) {
$ConfirmInstall = Confirm-Installation $($app.Id) $($app.AvailableVersion)
if ($ConfirmInstall -ne $true) {
#Upgrade failed!
#Test for a Pending Reboot (Component Based Servicing/WindowsUpdate/CCM_ClientUtilities)
$PendingReboot = Test-PendingReboot
@ -76,14 +75,11 @@ Function Update-App ($app) {
}
#Check if application installed properly
$CheckOutdated2 = Get-WingetOutdatedApps
foreach ($CheckApp2 in $CheckOutdated2) {
if ($($CheckApp2.Id) -eq $($app.Id)) {
$ConfirmInstall = Confirm-Installation $($app.Id) $($app.AvailableVersion)
if ($ConfirmInstall -eq $false) {
$FailedToUpgrade = $true
}
}
}
}
if ($FailedToUpgrade -eq $false) {
if ($ModsInstalled) {