Test Pending Reboot corect now (before upgrades

pull/136/head
GAJ-san 2022-08-01 13:25:14 +02:00
parent b482503008
commit da5d9aa083
1 changed files with 18 additions and 19 deletions

View File

@ -16,6 +16,9 @@ Function Update-App ($app) {
#Winget upgrade #Winget upgrade
Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray" Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
#Test for a Pending Reboot (Component Based Servicing/WindowsUpdate/CCM_ClientUtilities)
$PendingReboot = Test-PendingReboot
#Run Winget Upgrade command #Run Winget Upgrade command
& $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append & $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
@ -28,28 +31,20 @@ Function Update-App ($app) {
foreach ($CheckApp in $CheckOutdated) { foreach ($CheckApp in $CheckOutdated) {
if ($($CheckApp.Id) -eq $($app.Id)) { if ($($CheckApp.Id) -eq $($app.Id)) {
#Test for a Pending Reboot (Component Based Servicing/WindowsUpdate/CCM_ClientUtilities) #If app failed to upgrade, run Install command
$PendingReboot = Test-PendingReboot & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
if ($PendingReboot -eq $true) {
Write-Log "A Pending Reboot probably prohibited $($app.Id) from upgrading, now trying an install..." "Red"
}
#If app failed to upgrade, run Install command
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
#Set mods to apply as an install #Set mods to apply as an install
$ModsMode = "Install" $ModsMode = "Install"
#Check if application installed properly #Check if application installed properly
$CheckOutdated2 = Get-WingetOutdatedApps $CheckOutdated2 = Get-WingetOutdatedApps
foreach ($CheckApp2 in $CheckOutdated2) { foreach ($CheckApp2 in $CheckOutdated2) {
if ($($CheckApp2.Id) -eq $($app.Id)) { if ($($CheckApp2.Id) -eq $($app.Id)) {
#If app failed to install #If app failed to install
if ($PendingReboot -eq $true) { $FailedToUpgrade = $true
Write-Log "...a Pending Reboot probably prohibited $($app.Id) also from installing..." "Red"
}
$FailedToUpgrade = $true
}
} }
}
} }
} }
@ -88,6 +83,10 @@ Function Update-App ($app) {
} }
else { else {
if ($PendingReboot -eq $true) {
Write-Log "A Pending Reboot probably prohibited $($app.Id) from upgrading..." "Red"
}
#Send failed updated app notification #Send failed updated app notification
Write-Log "$($app.Name) update failed." "Red" Write-Log "$($app.Name) update failed." "Red"