Merge pull request #221 from Romanitho/main

update from main
pull/214/head
Romain 2022-10-27 00:50:51 +02:00 committed by GitHub
commit 8ad9012ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 37 deletions

View File

@ -49,9 +49,10 @@ if (Test-Network) {
#Get Current Version
$WAUCurrentVersion = $WAUConfig.DisplayVersion
Write-Log "WAU current version: $WAUCurrentVersion"
if ($IsSystem) {
#Check if WAU update feature is enabled or not
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
#If yes then check WAU update
#If yes then check WAU update if System
if ($WAUDisableAutoUpdate -eq 1) {
Write-Log "WAU AutoUpdate is Disabled." "Grey"
}
@ -63,20 +64,14 @@ if (Test-Network) {
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) {
#If new version is available, update it
Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow"
if ($IsSystem) {
Update-WAU
}
else {
Write-Log "WAU Needs to run as system to update" "Yellow"
}
}
else {
Write-Log "WAU is up to date." "Green"
}
}
if ($IsSystem) {
#Get External ListPath
#Get External ListPath if System
if ($WAUConfig.WAU_ListPath) {
Write-Log "WAU uses External Lists from: $($WAUConfig.WAU_ListPath)"
$NewList = Test-ListPath $WAUConfig.WAU_ListPath $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation
@ -168,25 +163,24 @@ if (Test-Network) {
if ($InstallOK -eq 0) {
Write-Log "No new update." "Green"
}
}
}
#Run WAU in user context if currently as system
if ($IsSystem) {
#Run WAU in user context if currently as system and the user task exist
$UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue
if ($IsSystem -and $UserScheduledTask) {
#Get Winget system apps to excape them befor running user context
Write-Log "Get list of installed Winget apps in System 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 {
elseif (!$UserScheduledTask){
Write-Log "User context execution not installed"
}
}
}
#End