Use Case
The scheduled_task type currently exposes compatibility and enabled from the underlying ITaskSettings interface, but omits the rest of the commonly-needed settings. For example ExecutionTimeLimit ("Stop the task if it runs longer than X"). This forces users who need those settings to fall back to dsc_scheduledtask, a custom exec running schtasks.exe / Register-ScheduledTask, or a local fork of this module.
In our environment we hit this with a PowerShell scheduled task that occasionally hangs; the task's own "Stop if runs longer than" setting would kill it after 30 minutes, but we can't manage that setting idempotently through Puppet today. We'd prefer not to switch the task to dsc_scheduledtask just for one property, since the native scheduled_task type is lighter and fits the rest of our manifest cleanly.
Looking at the upstream Task Scheduler 2.0 COM interface (ITaskSettings), all of these are exposed on the same TaskDefinition.Settings object we already read for Enabled and Compatibility, so the provider-side work is small.
Describe the Solution You Would Like
Add the following properties to the scheduled_task type, backed by getters/setters on the taskscheduler_api2 provider that delegate to the existing @definition.Settings object:
| Property |
ITaskSettings member |
Type / format |
execution_time_limit |
ExecutionTimeLimit |
ISO 8601 duration string (e.g. PT30M), or '' to disable |
allow_demand_start |
AllowDemandStart |
boolean |
start_when_available |
StartWhenAvailable |
boolean |
run_only_if_network_available |
RunOnlyIfNetworkAvailable |
boolean |
stop_if_going_on_batteries |
StopIfGoingOnBatteries |
boolean |
disallow_start_if_on_batteries |
DisallowStartIfOnBatteries |
boolean |
wake_to_run |
WakeToRun |
boolean |
run_only_if_idle |
RunOnlyIfIdle |
boolean |
restart_count |
RestartCount |
integer |
restart_interval |
RestartInterval |
ISO 8601 duration |
priority |
Priority |
integer 0-10 |
multiple_instances |
MultipleInstances |
enum matching TASK_INSTANCES_POLICY (parallel, queue, ignore_new, stop_existing) |
Additional Context
Add any other context or screenshots about the feature request here.
Use Case
The
scheduled_tasktype currently exposescompatibilityandenabledfrom the underlyingITaskSettingsinterface, but omits the rest of the commonly-needed settings. For exampleExecutionTimeLimit("Stop the task if it runs longer than X"). This forces users who need those settings to fall back todsc_scheduledtask, a custom exec runningschtasks.exe/Register-ScheduledTask, or a local fork of this module.In our environment we hit this with a PowerShell scheduled task that occasionally hangs; the task's own "Stop if runs longer than" setting would kill it after 30 minutes, but we can't manage that setting idempotently through Puppet today. We'd prefer not to switch the task to
dsc_scheduledtaskjust for one property, since the nativescheduled_tasktype is lighter and fits the rest of our manifest cleanly.Looking at the upstream Task Scheduler 2.0 COM interface (ITaskSettings), all of these are exposed on the same
TaskDefinition.Settingsobject we already read forEnabledandCompatibility, so the provider-side work is small.Describe the Solution You Would Like
Add the following properties to the
scheduled_tasktype, backed by getters/setters on thetaskscheduler_api2provider that delegate to the existing@definition.Settingsobject:execution_time_limitExecutionTimeLimitPT30M), or''to disableallow_demand_startAllowDemandStartstart_when_availableStartWhenAvailablerun_only_if_network_availableRunOnlyIfNetworkAvailablestop_if_going_on_batteriesStopIfGoingOnBatteriesdisallow_start_if_on_batteriesDisallowStartIfOnBatterieswake_to_runWakeToRunrun_only_if_idleRunOnlyIfIdlerestart_countRestartCountrestart_intervalRestartIntervalpriorityPrioritymultiple_instancesMultipleInstancesTASK_INSTANCES_POLICY(parallel,queue,ignore_new,stop_existing)Additional Context
Add any other context or screenshots about the feature request here.