Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9673

Configuring a scheduled task to run whether or not a user is logged in Powershell

$
0
0

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?


Viewing all articles
Browse latest Browse all 9673

Trending Articles