community.windows.win_scheduled_task_stat module – Get information about Windows Scheduled Tasks
Note
This module is part of the community.windows collection (version 1.10.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.windows
.
To use it in a playbook, specify: community.windows.win_scheduled_task_stat
.
Synopsis
Will return whether the folder and task exists.
Returns the names of tasks in the folder specified.
Use community.windows.win_scheduled_task to configure a scheduled task.
Parameters
Parameter |
Comments |
---|---|
The name of the scheduled task to get information for. If |
|
The folder path where the task lives. Default: “\\” |
See Also
See also
- community.windows.win_scheduled_task
The official documentation on the community.windows.win_scheduled_task module.
Examples
- name: Get information about a folder
community.windows.win_scheduled_task_stat:
path: \folder name
register: task_folder_stat
- name: Get information about a task in the root folder
community.windows.win_scheduled_task_stat:
name: task name
register: task_stat
- name: Get information about a task in a custom folder
community.windows.win_scheduled_task_stat:
path: \folder name
name: task name
register: task_stat
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
A list of actions. Returned: name is specified and task exists Sample: [{“Arguments”: “/c echo hi”, “Id”: null, “Path”: “cmd.exe”, “Type”: “TASK_ACTION_EXEC”, “WorkingDirectory”: null}] |
|
Whether the folder set at path exists. Returned: always Sample: true |
|
The number of tasks that exist in the folder. Returned: always Sample: 2 |
|
A list of tasks that exist in the folder. Returned: always Sample: [“Task 1”, “Task 2”] |
|
Details on the principal configured to run the task. Returned: name is specified and task exists |
|
The name of the user/group that is displayed in the Task Scheduler UI. Sample: “Administrator” |
|
The group that will run the task. Sample: “BUILTIN\\Administrators” |
|
The ID for the principal. Sample: “Author” |
|
The logon method that the task will run with. Sample: “TASK_LOGON_INTERACTIVE_TOKEN” |
|
The level of user rights used to run the task. Sample: “TASK_RUNLEVEL_LUA” |
|
The user that will run the task. Sample: “SERVER\\Administrator” |
|
Details on the task registration info. Returned: name is specified and task exists |
|
The author os the task. Sample: “SERVER\\Administrator” |
|
The date when the task was register. Sample: “2017-01-01T10:00:00” |
|
The description of the task. Sample: “task description” |
|
The documentation of the task. Sample: “task documentation” |
|
The security descriptor of the task. Sample: “security descriptor” |
|
The source of the task. Sample: “source” |
|
The URI/path of the task. Sample: “\\task\\task name” |
|
The version of the task. Sample: 1.0 |
|
Details on the task settings. Returned: name is specified and task exists |
|
Whether the task can be started by using either the Run command of the Context menu. Sample: true |
|
Whether the task can terminated by using TerminateProcess. Sample: true |
|
The compatibility level of the task Sample: 2 |
|
The amount of time the Task Scheduler will wait before deleting the task after it expires. Sample: “PT10M” |
|
Whether the task will not be started if the computer is running on battery power. Sample: false |
|
Whether the task will not be started when in a remote app session. Sample: true |
|
Whether the task is enabled. Sample: true |
|
The amount of time allowed to complete the task. Sample: “PT72H” |
|
Whether the task is hidden in the UI. Sample: false |
|
The idle settings of the task. Sample: {“idle_duration”: “PT10M”, “restart_on_idle”: false, “stop_on_idle_end”: true, “wait_timeout”: “PT1H”} |
|
The maintenance settings of the task. |
|
Indicates the behaviour when starting a task that is already running. Sample: 2 |
|
The network settings of the task. Sample: {“id”: null, “name”: null} |
|
The priority level of the task. Sample: 7 |
|
The number of times that the task will attempt to restart on failures. Sample: 0 |
|
How long the Task Scheduler will attempt to restart the task. Sample: “PT15M” |
|
Whether the task will run if the computer is in an idle state. Sample: true |
|
Whether the task will run only when a network is available. Sample: false |
|
Whether the task can start at any time after its scheduled time has passed. Sample: false |
|
Whether the task will be stopped if the computer begins to run on battery power. Sample: true |
|
Whether the task will use the unified scheduling engine. Sample: false |
|
Whether the task is volatile. Sample: false |
|
Whether the task will wake the computer when it is time to run the task. Sample: false |
|
Details on the state of the task Returned: name is specified and task exists |
|
The time the registered task was last run. Sample: “2017-09-20T20:50:00” |
|
The results that were returned the last time the task was run. Sample: 267009 |
|
The time when the task is next scheduled to run. Sample: “2017-09-20T22:50:00” |
|
The number of times a task has missed a scheduled run. Sample: 1 |
|
The status of the task, whether it is running, stopped, etc. Sample: “TASK_STATE_RUNNING” |
|
Whether the task at the folder exists. Returned: name is specified Sample: true |
|
A list of triggers. Returned: name is specified and task exists Sample: [{“delay”: “PT15M”, “enabled”: true, “end_boundary”: null, “execution_time_limit”: null, “id”: null, “repetition”: {“duration”: null, “interval”: null, “stop_at_duration_end”: false}, “start_boundary”: null, “type”: “TASK_TRIGGER_BOOT”}, {“days_of_month”: “5,15,30”, “enabled”: true, “end_boundary”: null, “execution_time_limit”: null, “id”: null, “months_of_year”: “june,december”, “random_delay”: null, “repetition”: {“duration”: null, “interval”: null, “stop_at_duration_end”: false}, “run_on_last_day_of_month”: true, “start_boundary”: “2017-09-20T03:44:38”, “type”: “TASK_TRIGGER_MONTHLY”}] |
Authors
Jordan Borean (@jborean93)