I'm having issues with creating scheduled task remotely on a computer.
This is my script:
$Action = New-ScheduledTaskAction -Execute "Robocopy" -Argument"""$downloadDirectory"" ""$fullDirectory"" /e /mt:32 /r:2 /w:2 /z /eta"
Register-ScheduledTask -User (Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object -expand UserName) -Action $Action -TaskName "ScriptUtilFileCopy" -Force
Start-ScheduledTask -TaskName "ScriptUtilFileCopy"
The scheduled task will be run as the local user, not the account used to remote in with.
However, when I run Start-ScheduledTask
remotely, the task is set to Queued
with the code 0x0
in the Task Scheduler interface. But, if I run the task from Task Scheduled (ie. Right-Click --> Run), the task is run successfully.