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
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
& $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
@ -28,11 +31,6 @@ Function Update-App ($app) {
foreach ($CheckApp in $CheckOutdated) {
if ($($CheckApp.Id) -eq $($app.Id)) {
#Test for a Pending Reboot (Component Based Servicing/WindowsUpdate/CCM_ClientUtilities)
$PendingReboot = Test-PendingReboot
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
@ -44,9 +42,6 @@ Function Update-App ($app) {
foreach ($CheckApp2 in $CheckOutdated2) {
if ($($CheckApp2.Id) -eq $($app.Id)) {
#If app failed to install
if ($PendingReboot -eq $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 {
if ($PendingReboot -eq $true) {
Write-Log "A Pending Reboot probably prohibited $($app.Id) from upgrading..." "Red"
}
#Send failed updated app notification
Write-Log "$($app.Name) update failed." "Red"