Improved application detection after upgrade

pull/356/head
romanitho 2023-06-21 15:47:38 +02:00
parent 5efbb98eb1
commit d8d71536e2
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 #Config console output encoding
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [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 $caller = Get-ChildItem $MyInvocation.PSCommandPath | Select-Object -Expand Name
if ($caller -eq "Winget-Upgrade.ps1") { if ($caller -eq "Winget-Upgrade.ps1") {
#Log Header #Log Header

View File

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

View File

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