W3cubDocs

/Ansible 2.9

win_scheduled_task_stat – Get information about Windows Scheduled Tasks

New in version 2.5.

Synopsis

  • Will return whether the folder and task exists.
  • Returns the names of tasks in the folder specified.
  • Use win_scheduled_task to configure a scheduled task.

Parameters

Parameter Choices/Defaults Comments
name
string
The name of the scheduled task to get information for.
If name is set and exists, will return information on the task itself.
path
string
Default:
"\\"
The folder path where the task lives.

See Also

See also

win_scheduled_task – Manage scheduled tasks
The official documentation on the win_scheduled_task module.

Examples

- name: Get information about a folder
  win_scheduled_task_stat:
    path: \folder name
  register: task_folder_stat

- name: Get information about a task in the root folder
  win_scheduled_task_stat:
    name: task name
  register: task_stat

- name: Get information about a task in a custom folder
  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 Returned Description
actions
list
name is specified and task exists
A list of actions.

Sample:
[{'Arguments': '/c echo hi', 'Id': None, 'Path': 'cmd.exe', 'Type': 'TASK_ACTION_EXEC', 'WorkingDirectory': None}]
folder_exists
boolean
always
Whether the folder set at path exists.

Sample:
True
folder_task_count
integer
always
The number of tasks that exist in the folder.

Sample:
2
folder_task_names
list
always
A list of tasks that exist in the folder.

Sample:
['Task 1', 'Task 2']
principal
complex
name is specified and task exists
Details on the principal configured to run the task.

display_name
string
The name of the user/group that is displayed in the Task Scheduler UI.

Sample:
Administrator
group_id
string
The group that will run the task.

Sample:
BUILTIN\Administrators
id
string
The ID for the principal.

Sample:
Author
logon_type
string
The logon method that the task will run with.

Sample:
TASK_LOGON_INTERACTIVE_TOKEN
run_level
string
The level of user rights used to run the task.

Sample:
TASK_RUNLEVEL_LUA
user_id
string
The user that will run the task.

Sample:
SERVER\Administrator
registration_info
complex
name is specified and task exists
Details on the task registration info.

author
string
The author os the task.

Sample:
SERVER\Administrator
date
string
The date when the task was register.

Sample:
2017-01-01T10:00:00
description
string
The description of the task.

Sample:
task description
documentation
string
The documentation of the task.

Sample:
task documentation
security_descriptor
string
The security descriptor of the task.

Sample:
security descriptor
source
string
The source of the task.

Sample:
source
uri
string
The URI/path of the task.

Sample:
\task\task name
version
string
The version of the task.

Sample:
1.0
settings
complex
name is specified and task exists
Details on the task settings.

allow_demand_start
boolean
Whether the task can be started by using either the Run command of the Context menu.

Sample:
True
allow_hard_terminate
boolean
Whether the task can terminated by using TerminateProcess.

Sample:
True
compatibility
integer
The compatibility level of the task

Sample:
2
delete_expired_task_after
string
The amount of time the Task Scheduler will wait before deleting the task after it expires.

Sample:
PT10M
disallow_start_if_on_batteries
boolean
Whether the task will not be started if the computer is running on battery power.

disallow_start_on_remote_app_session
boolean
Whether the task will not be started when in a remote app session.

Sample:
True
enabled
boolean
Whether the task is enabled.

Sample:
True
execution_time_limit
string
The amount of time allowed to complete the task.

Sample:
PT72H
hidden
boolean
Whether the task is hidden in the UI.

idle_settings
dictionary
The idle settings of the task.

Sample:
{'idle_duration': 'PT10M', 'restart_on_idle': False, 'stop_on_idle_end': True, 'wait_timeout': 'PT1H'}
maintenance_settings
string
The maintenance settings of the task.

mulitple_instances
integer
Indicates the behaviour when starting a task that is already running.

Sample:
2
network_settings
dictionary
The network settings of the task.

Sample:
{'id': None, 'name': None}
priority
integer
The priority level of the task.

Sample:
7
restart_count
integer
The number of times that the task will attempt to restart on failures.

restart_interval
string
How long the Task Scheduler will attempt to restart the task.

Sample:
PT15M
run_only_id_idle
boolean
Whether the task will run if the computer is in an idle state.

Sample:
True
run_only_if_network_available
boolean
Whether the task will run only when a network is available.

start_when_available
boolean
Whether the task can start at any time after its scheduled time has passed.

stop_if_going_on_batteries
boolean
Whether the task will be stopped if the computer begins to run on battery power.

Sample:
True
use_unified_scheduling_engine
boolean
Whether the task will use the unified scheduling engine.

volatile
boolean
Whether the task is volatile.

wake_to_run
boolean
Whether the task will wake the computer when it is time to run the task.

state
complex
name is specified and task exists
Details on the state of the task

last_run_time
string
The time the registered task was last run.

Sample:
2017-09-20T20:50:00
last_task_result
integer
The results that were returned the last time the task was run.

Sample:
267009
next_run_time
string
The time when the task is next scheduled to run.

Sample:
2017-09-20T22:50:00
number_of_missed_runs
integer
The number of times a task has missed a scheduled run.

Sample:
1
status
string
The status of the task, whether it is running, stopped, etc.

Sample:
TASK_STATE_RUNNING
task_exists
boolean
name is specified
Whether the task at the folder exists.

Sample:
True
triggers
list
name is specified and task exists
A list of triggers.

Sample:
[{'delay': 'PT15M', 'enabled': True, 'end_boundary': None, 'execution_time_limit': None, 'id': None, 'repetition': {'duration': None, 'interval': None, 'stop_at_duration_end': False}, 'start_boundary': None, 'type': 'TASK_TRIGGER_BOOT'}, {'days_of_month': '5,15,30', 'enabled': True, 'end_boundary': None, 'execution_time_limit': None, 'id': None, 'months_of_year': 'june,december', 'random_delay': None, 'repetition': {'duration': None, 'interval': None, 'stop_at_duration_end': False}, 'run_on_last_day_of_month': True, 'start_boundary': '2017-09-20T03:44:38', 'type': 'TASK_TRIGGER_MONTHLY'}]


Status

Authors

  • Jordan Borean (@jborean93)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/win_scheduled_task_stat_module.html