commit
d5c9d0df4f
|
@ -49,9 +49,10 @@ 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"
|
||||||
|
if ($IsSystem) {
|
||||||
#Check if WAU update feature is enabled or not
|
#Check if WAU update feature is enabled or not
|
||||||
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
|
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
|
||||||
#If yes then check WAU update
|
#If yes then check WAU update if System
|
||||||
if ($WAUDisableAutoUpdate -eq 1) {
|
if ($WAUDisableAutoUpdate -eq 1) {
|
||||||
Write-Log "WAU AutoUpdate is Disabled." "Grey"
|
Write-Log "WAU AutoUpdate is Disabled." "Grey"
|
||||||
}
|
}
|
||||||
|
@ -63,20 +64,14 @@ if (Test-Network) {
|
||||||
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) {
|
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) {
|
||||||
#If new version is available, update it
|
#If new version is available, update it
|
||||||
Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow"
|
Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow"
|
||||||
if ($IsSystem) {
|
|
||||||
Update-WAU
|
Update-WAU
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Write-Log "WAU Needs to run as system to update" "Yellow"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
Write-Log "WAU is up to date." "Green"
|
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,26 +163,25 @@ 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
|
||||||
|
Write-Log "Get list of installed Winget apps in System context..."
|
||||||
Get-WingetSystemApps
|
Get-WingetSystemApps
|
||||||
|
|
||||||
#Run user context scheduled task
|
#Run user context scheduled task
|
||||||
$UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue
|
|
||||||
if ($UserScheduledTask) {
|
|
||||||
Write-Log "Starting WAU in User context"
|
Write-Log "Starting WAU in User context"
|
||||||
Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
|
Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
|
||||||
Exit 0
|
Exit 0
|
||||||
}
|
}
|
||||||
else {
|
elseif (!$UserScheduledTask){
|
||||||
Write-Log "User context execution not installed"
|
Write-Log "User context execution not installed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#End
|
#End
|
||||||
Write-Log "End of process!" "Cyan"
|
Write-Log "End of process!" "Cyan"
|
||||||
|
|
Loading…
Reference in New Issue