I'm setting up scheduled tasks in Windows Server 2016 through Powershell (not through schtasks.exe
).
$user = "Administrator"$trigger = New-ScheduledTaskTrigger -Daily -At 0:00 $action = New-ScheduledTaskAction -Execute "C:\Windows\System32\forfiles.exe" -Argument '/p "C:\example"'Register-ScheduledTask -Action $action -Trigger $trigger -User $user -TaskName "foobar"
The tasks do not run. Run only if user is logged in
is enabled on the new tasks. I want to try to see if the tasks run if Run whether user is logged in or not
is enabled.
I don't see anything in the New-ScheduledTaskSettingsSet documentation regarding this.
Is there a way to do this through Powershell?