Skip to content

Expose ITaskSettings properties (ExecutionTimeLimit, etc.) on the scheduled_task type #274

Description

@kruegerkyle95

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions