optimization

pull/410/head
romanitho 2023-10-09 15:17:24 +02:00
parent eadf4136ed
commit e188435b6c
1 changed files with 4 additions and 1 deletions

View File

@ -321,6 +321,9 @@ if (Test-Network) {
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
Register-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -TaskPath 'WAU' -InputObject $task -Force | Out-Null Register-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
Write-ToLog "-> User Context task created." Write-ToLog "-> User Context task created."
#Load it
$UserContextTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue
} }
#User check routine from: https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-domain-and-machine-status #User check routine from: https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-domain-and-machine-status
@ -335,7 +338,7 @@ if (Test-Network) {
#Run user context scheduled task #Run user context scheduled task
Write-ToLog "Starting WAU in User context..." Write-ToLog "Starting WAU in User context..."
Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue $null = $UserContextTask | Start-ScheduledTask -ErrorAction SilentlyContinue
Exit 0 Exit 0
} }
} }