commit
8ad9012ba6
|
@ -49,34 +49,29 @@ if (Test-Network) {
|
||||||
#Get Current Version
|
#Get Current Version
|
||||||
$WAUCurrentVersion = $WAUConfig.DisplayVersion
|
$WAUCurrentVersion = $WAUConfig.DisplayVersion
|
||||||
Write-Log "WAU current version: $WAUCurrentVersion"
|
Write-Log "WAU current version: $WAUCurrentVersion"
|
||||||
#Check if WAU update feature is enabled or not
|
if ($IsSystem) {
|
||||||
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
|
#Check if WAU update feature is enabled or not
|
||||||
#If yes then check WAU update
|
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
|
||||||
if ($WAUDisableAutoUpdate -eq 1) {
|
#If yes then check WAU update if System
|
||||||
Write-Log "WAU AutoUpdate is Disabled." "Grey"
|
if ($WAUDisableAutoUpdate -eq 1) {
|
||||||
}
|
Write-Log "WAU AutoUpdate is Disabled." "Grey"
|
||||||
else {
|
}
|
||||||
Write-Log "WAU AutoUpdate is Enabled." "Green"
|
else {
|
||||||
#Get Available Version
|
Write-Log "WAU AutoUpdate is Enabled." "Green"
|
||||||
$WAUAvailableVersion = Get-WAUAvailableVersion
|
#Get Available Version
|
||||||
#Compare
|
$WAUAvailableVersion = Get-WAUAvailableVersion
|
||||||
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) {
|
#Compare
|
||||||
#If new version is available, update it
|
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) {
|
||||||
Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow"
|
#If new version is available, update it
|
||||||
if ($IsSystem) {
|
Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow"
|
||||||
Update-WAU
|
Update-WAU
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Log "WAU Needs to run as system to update" "Yellow"
|
Write-Log "WAU is up to date." "Green"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Write-Log "WAU is up to date." "Green"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($IsSystem) {
|
#Get External ListPath if System
|
||||||
#Get External ListPath
|
|
||||||
if ($WAUConfig.WAU_ListPath) {
|
if ($WAUConfig.WAU_ListPath) {
|
||||||
Write-Log "WAU uses External Lists from: $($WAUConfig.WAU_ListPath)"
|
Write-Log "WAU uses External Lists from: $($WAUConfig.WAU_ListPath)"
|
||||||
$NewList = Test-ListPath $WAUConfig.WAU_ListPath $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation
|
$NewList = Test-ListPath $WAUConfig.WAU_ListPath $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation
|
||||||
|
@ -168,24 +163,23 @@ if (Test-Network) {
|
||||||
if ($InstallOK -eq 0) {
|
if ($InstallOK -eq 0) {
|
||||||
Write-Log "No new update." "Green"
|
Write-Log "No new update." "Green"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Run WAU in user context if currently as system
|
#Run WAU in user context if currently as system and the user task exist
|
||||||
if ($IsSystem) {
|
$UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue
|
||||||
|
if ($IsSystem -and $UserScheduledTask) {
|
||||||
|
|
||||||
#Get Winget system apps to excape them befor running user context
|
#Get Winget system apps to excape them befor running user context
|
||||||
Get-WingetSystemApps
|
Write-Log "Get list of installed Winget apps in System context..."
|
||||||
|
Get-WingetSystemApps
|
||||||
|
|
||||||
#Run user context scheduled task
|
#Run user context scheduled task
|
||||||
$UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue
|
Write-Log "Starting WAU in User context"
|
||||||
if ($UserScheduledTask) {
|
Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
|
||||||
Write-Log "Starting WAU in User context"
|
Exit 0
|
||||||
Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
|
}
|
||||||
Exit 0
|
elseif (!$UserScheduledTask){
|
||||||
}
|
Write-Log "User context execution not installed"
|
||||||
else {
|
}
|
||||||
Write-Log "User context execution not installed"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue