win_scheduled_task_stat - Get information about Windows Scheduled Tasks

New in version 2.5.

Synopsis

Parameters

Parameter Choices/Defaults Comments
name
The name of the scheduled task to get information for.
path Default:
\
The folder path where the task lives.

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:
[{'Path': 'cmd.exe', 'Type': 'TASK_ACTION_EXEC', 'Arguments': '/c echo hi', 'WorkingDirectory': None, 'Id': None}]
folder_exists
boolean
always
Whether the folder set at path exists.

Sample:
True
folder_task_count
int
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.

  user_id
str
The user that will run the task.

Sample:
SERVER\Administrator
  logon_type
str
The logon method that the task will run with.

Sample:
TASK_LOGON_INTERACTIVE_TOKEN
  display_name
str
The name of the user/group that is displayed in the Task Scheduler UI.

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

Sample:
BUILTIN\Administrators
  run_level
str
The level of user rights used to run the task.

Sample:
TASK_RUNLEVEL_LUA
  id
str
The ID for the principal.

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

  description
str
The description of the task.

Sample:
task description
  author
str
The author os the task.

Sample:
SERVER\Administrator
  documentation
str
The documentation of the task.

Sample:
task documentation
  uri
str
The URI/path of the task.

Sample:
\task\task name
  source
str
The source of the task.

Sample:
source
  version
str
The version of the task.

Sample:
1.0
  date
str
The date when the task was register.

Sample:
2017-01-01T10:00:00
  security_descriptor
str
The security descriptor of the task.

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

  run_only_if_network_available
bool
Whether the task will run only when a network is available.

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

Sample:
2
  execution_time_limit
str
The amount of time allowed to complete the task.

Sample:
PT72H
  idle_settings
dictionary
The idle settings of the task.

Sample:
{'restart_on_idle': False, 'wait_timeout': 'PT1H', 'idle_duration': 'PT10M', 'stop_on_idle_end': True}
  disallow_start_if_on_batteries
bool
Whether the task will not be started if the computer is running on battery power.

  run_only_id_idle
bool
Whether the task will run if the computer is in an idle state.

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

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

Sample:
{'id': None, 'name': None}
  disallow_start_on_remote_app_session
bool
Whether the task will not be started when in a remote app session.

Sample:
True
  restart_interval
str
How long the Task Scheduler will attempt to restart the task.

Sample:
PT15M
  stop_if_going_on_batteries
bool
Whether the task will be stopped if the computer begins to run on battery power.

Sample:
True
  use_unified_scheduling_engine
bool
Whether the task will use the unifed scheduling engine.

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

  compatibility
int
The compatibility level of the task

Sample:
2
  maintenance_settings
str
The maintenance settings of the task.

  restart_count
int
The number of times that the task will attempt to restart on failures.

  priority
int
The priority level of the task.

Sample:
7
  start_when_available
bool
Whether the task can start at any time after its scheduled time has passed.

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

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

Sample:
True
  volatile
bool
Whether thet ask is volatile.

  hidden
bool
Whether the task is hidden in the UI.

  enabled
bool
Whether the task is enabled.

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

  last_task_result
int
The results that were returned the last time the task was run.

Sample:
267009
  number_of_missed_runs
int
The number of times a task has missed a scheduled run.

Sample:
1
  next_run_time
str
The time when the task is next scheduled to run.

Sample:
2017-09-20T22:50:00
  status
str
The status of the task, whether it is running, stopped, etc.

Sample:
TASK_STATE_RUNNING
  last_run_time
str
The time the registered task was last run.

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


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

Author

  • Jordan Borean (@jborean93)

Hint

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