From 21b5fa8269173e0bfed434ed847d87dd6c1c8654 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 26 Oct 2022 21:58:36 +0200 Subject: [PATCH] If !$TestWinget no need to continue? --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 0c868af..9e0006c 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -165,23 +165,23 @@ if (Test-Network) { if ($InstallOK -eq 0) { Write-Log "No new update." "Green" } - } - - #Run WAU in user context if currently as system - if ($IsSystem) { - #Get Winget system apps to excape them befor running user context - Get-WingetSystemApps + #Run WAU in user context if currently as system + if ($IsSystem) { - #Run user context scheduled task - $UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue - if ($UserScheduledTask) { - Write-Log "Starting WAU in User context" - Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue - Exit 0 - } - else { - Write-Log "User context execution not installed" + #Get Winget system apps to excape them befor running user context + Get-WingetSystemApps + + #Run user context scheduled task + $UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue + if ($UserScheduledTask) { + Write-Log "Starting WAU in User context" + Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue + Exit 0 + } + else { + Write-Log "User context execution not installed" + } } } }