I know you can create and edit the actions and triggers of a scheduled task via CMD, but when I open the created task in Task Scheduler all of the Conditions are set to their default configurations. I've tried looking them up in the microsoft documentation but all I've been able to find are the switches /options for the actions and triggers portion of the scheduled task.
I'd like to be able to do this via Command line so that I can deploy this scheduled task to all of our Windows 10 workstations with PDQ deploy.
For reference, here is the command I am currently working with
'schtasks /create /tn SeatSaver /tr "taskkill /F /IM Executable.EXE" /sc
ONIDLE /i 60 /ru domain\username /rp password'
according to the documentation this command should create a task that kills a certain program after 60 minutes of the Workstation being idle. But when I open up the created task and look at the conditions, the options for conditions are all at their default settings, which to me means that the command won't work as is, because the default setting for idling is to not care if the PC is idle, which I don't want.
Is there anyway to make this work via CMD?
Edit: I've read through Microsoft's Powershell Documentation for this, but I wasn't able to find anything regarding the "OnIdle" trigger, or if it even exists. Does anyone have a list of Triggers for setting up scheduled tasks with Powershell?
The
New-ScheduledTask
command has a settings parameter that accepts a settings object, which can be created usingNew-ScheduledTaskSettingsSet
and that has a-RunOnlyIfIdle
parameter.This implies that 'on idle' is not a trigger in itself, but a limiting control on the trigger that stops the task running if the host is not idle.
Perhaps in
CMD
you also require a periodic schedule to get yourONIDLE
, such as by using the/MO
and/ST
parameters.Alright, I'm an idiot. I just realized you can export Scheduled tasks as xml files then create a new task using the schtasks /create /xml "xmlfile.xml" command. I'm just going to do that and deploy it with PDQ.
Thanks guys.