Why does my scheduled task sit queued until the first time someone logs in?

i8displaynames 6 Reputation points
2022-11-09T16:15:18.657+00:00

I am having a problem getting Avid Pro Tools to install using Configuration Manager. The software install fails when run by the system user but works fine for other admin accounts. To get round this I tried running the install using impersonation only to find the the system user isn't allowed to do this. My next plan was to create a scheduled task, which runs as a specified user and initiate it using a script. This seems to work but for some reason when deploying to a new computer the task sits queued until the first time someone logs in. This is the script I am using

$taskname = "install protools"

$user = "tempadmin"

$password = "tempadminpass1"

$securepassword = ConvertTo-SecureString "$password" -AsPlainText -Force

New-LocalUser "$user" -Password $securepassword -FullName "$user" -Description "Temporary local admin"

Add-LocalGroupMember -Group "Administrators" -Member "$user"

$command = "setup.exe"

$arguments = '/S /v"/qn /norestart"'

$StartIn = pwd

$action = New-ScheduledTaskAction -Execute $command -argument $arguments -WorkingDirectory $startin

Register-ScheduledTask -TaskName $taskname -User $User -password $password -Action $action

Start-ScheduledTask -TaskName $taskname

while ((Get-ScheduledTask -TaskName $taskname).State -ne 'Ready') {}

Unregister-ScheduledTask -TaskName $taskname -Confirm:$false

Remove-LocalUser -Name "$user"

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,618 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. i8displaynames 6 Reputation points
    2022-11-21T15:28:13.597+00:00

    Thanks for trying to help MotoX80. This is all happening after sysprep has completed so not relevant I don't believe. Everything that I am doing in regards to the task works, except in the scenario where if no one has ever logged into the computer the task is queued until someone does login at which point it runs. If someone has been logged in prior to the task being created and are either still logged in or no one is logged in the task will run without issue. I can log in to each computer to trigger the install its just frustrating having to when its supposed to be hands off install.