| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Copyright: (c) 2017, Ansible Project |
| 5 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
DOCUMENTATION = r''' |
| 8 |
--- |
| 9 |
module: win_scheduled_task_stat |
| 10 |
short_description: Get information about Windows Scheduled Tasks |
| 11 |
description: |
| 12 |
- Will return whether the folder and task exists. |
| 13 |
- Returns the names of tasks in the folder specified. |
| 14 |
- Use M(community.windows.win_scheduled_task) to configure a scheduled task. |
| 15 |
options: |
| 16 |
path: |
| 17 |
description: The folder path where the task lives. |
| 18 |
type: str |
| 19 |
default: \ |
| 20 |
name: |
| 21 |
description: |
| 22 |
- The name of the scheduled task to get information for. |
| 23 |
- If C(name) is set and exists, will return information on the task itself. |
| 24 |
type: str |
| 25 |
seealso: |
| 26 |
- module: community.windows.win_scheduled_task |
| 27 |
author: |
| 28 |
- Jordan Borean (@jborean93) |
| 29 |
''' |
| 30 |
|
| 31 |
EXAMPLES = r''' |
| 32 |
- name: Get information about a folder |
| 33 |
community.windows.win_scheduled_task_stat: |
| 34 |
path: \folder name |
| 35 |
register: task_folder_stat |
| 36 |
|
| 37 |
- name: Get information about a task in the root folder |
| 38 |
community.windows.win_scheduled_task_stat: |
| 39 |
name: task name |
| 40 |
register: task_stat |
| 41 |
|
| 42 |
- name: Get information about a task in a custom folder |
| 43 |
community.windows.win_scheduled_task_stat: |
| 44 |
path: \folder name |
| 45 |
name: task name |
| 46 |
register: task_stat |
| 47 |
''' |
| 48 |
|
| 49 |
RETURN = r''' |
| 50 |
actions: |
| 51 |
description: A list of actions. |
| 52 |
returned: name is specified and task exists |
| 53 |
type: list |
| 54 |
sample: [ |
| 55 |
{ |
| 56 |
"Arguments": "/c echo hi", |
| 57 |
"Id": null, |
| 58 |
"Path": "cmd.exe", |
| 59 |
"Type": "TASK_ACTION_EXEC", |
| 60 |
"WorkingDirectory": null |
| 61 |
} |
| 62 |
] |
| 63 |
folder_exists: |
| 64 |
description: Whether the folder set at path exists. |
| 65 |
returned: always |
| 66 |
type: bool |
| 67 |
sample: true |
| 68 |
folder_task_count: |
| 69 |
description: The number of tasks that exist in the folder. |
| 70 |
returned: always |
| 71 |
type: int |
| 72 |
sample: 2 |
| 73 |
folder_task_names: |
| 74 |
description: A list of tasks that exist in the folder. |
| 75 |
returned: always |
| 76 |
type: list |
| 77 |
sample: [ 'Task 1', 'Task 2' ] |
| 78 |
principal: |
| 79 |
description: Details on the principal configured to run the task. |
| 80 |
returned: name is specified and task exists |
| 81 |
type: complex |
| 82 |
contains: |
| 83 |
display_name: |
| 84 |
description: The name of the user/group that is displayed in the Task |
| 85 |
Scheduler UI. |
| 86 |
returned: '' |
| 87 |
type: str |
| 88 |
sample: Administrator |
| 89 |
group_id: |
| 90 |
description: The group that will run the task. |
| 91 |
returned: '' |
| 92 |
type: str |
| 93 |
sample: BUILTIN\Administrators |
| 94 |
id: |
| 95 |
description: The ID for the principal. |
| 96 |
returned: '' |
| 97 |
type: str |
| 98 |
sample: Author |
| 99 |
logon_type: |
| 100 |
description: The logon method that the task will run with. |
| 101 |
returned: '' |
| 102 |
type: str |
| 103 |
sample: TASK_LOGON_INTERACTIVE_TOKEN |
| 104 |
run_level: |
| 105 |
description: The level of user rights used to run the task. |
| 106 |
returned: '' |
| 107 |
type: str |
| 108 |
sample: TASK_RUNLEVEL_LUA |
| 109 |
user_id: |
| 110 |
description: The user that will run the task. |
| 111 |
returned: '' |
| 112 |
type: str |
| 113 |
sample: SERVER\Administrator |
| 114 |
registration_info: |
| 115 |
description: Details on the task registration info. |
| 116 |
returned: name is specified and task exists |
| 117 |
type: complex |
| 118 |
contains: |
| 119 |
author: |
| 120 |
description: The author os the task. |
| 121 |
returned: '' |
| 122 |
type: str |
| 123 |
sample: SERVER\Administrator |
| 124 |
date: |
| 125 |
description: The date when the task was register. |
| 126 |
returned: '' |
| 127 |
type: str |
| 128 |
sample: '2017-01-01T10:00:00' |
| 129 |
description: |
| 130 |
description: The description of the task. |
| 131 |
returned: '' |
| 132 |
type: str |
| 133 |
sample: task description |
| 134 |
documentation: |
| 135 |
description: The documentation of the task. |
| 136 |
returned: '' |
| 137 |
type: str |
| 138 |
sample: task documentation |
| 139 |
security_descriptor: |
| 140 |
description: The security descriptor of the task. |
| 141 |
returned: '' |
| 142 |
type: str |
| 143 |
sample: security descriptor |
| 144 |
source: |
| 145 |
description: The source of the task. |
| 146 |
returned: '' |
| 147 |
type: str |
| 148 |
sample: source |
| 149 |
uri: |
| 150 |
description: The URI/path of the task. |
| 151 |
returned: '' |
| 152 |
type: str |
| 153 |
sample: \task\task name |
| 154 |
version: |
| 155 |
description: The version of the task. |
| 156 |
returned: '' |
| 157 |
type: str |
| 158 |
sample: 1.0 |
| 159 |
settings: |
| 160 |
description: Details on the task settings. |
| 161 |
returned: name is specified and task exists |
| 162 |
type: complex |
| 163 |
contains: |
| 164 |
allow_demand_start: |
| 165 |
description: Whether the task can be started by using either the Run |
| 166 |
command of the Context menu. |
| 167 |
returned: '' |
| 168 |
type: bool |
| 169 |
sample: true |
| 170 |
allow_hard_terminate: |
| 171 |
description: Whether the task can terminated by using TerminateProcess. |
| 172 |
returned: '' |
| 173 |
type: bool |
| 174 |
sample: true |
| 175 |
compatibility: |
| 176 |
description: The compatibility level of the task |
| 177 |
returned: '' |
| 178 |
type: int |
| 179 |
sample: 2 |
| 180 |
delete_expired_task_after: |
| 181 |
description: The amount of time the Task Scheduler will wait before |
| 182 |
deleting the task after it expires. |
| 183 |
returned: '' |
| 184 |
type: str |
| 185 |
sample: PT10M |
| 186 |
disallow_start_if_on_batteries: |
| 187 |
description: Whether the task will not be started if the computer is |
| 188 |
running on battery power. |
| 189 |
returned: '' |
| 190 |
type: bool |
| 191 |
sample: false |
| 192 |
disallow_start_on_remote_app_session: |
| 193 |
description: Whether the task will not be started when in a remote app |
| 194 |
session. |
| 195 |
returned: '' |
| 196 |
type: bool |
| 197 |
sample: true |
| 198 |
enabled: |
| 199 |
description: Whether the task is enabled. |
| 200 |
returned: '' |
| 201 |
type: bool |
| 202 |
sample: true |
| 203 |
execution_time_limit: |
| 204 |
description: The amount of time allowed to complete the task. |
| 205 |
returned: '' |
| 206 |
type: str |
| 207 |
sample: PT72H |
| 208 |
hidden: |
| 209 |
description: Whether the task is hidden in the UI. |
| 210 |
returned: '' |
| 211 |
type: bool |
| 212 |
sample: false |
| 213 |
idle_settings: |
| 214 |
description: The idle settings of the task. |
| 215 |
returned: '' |
| 216 |
type: dict |
| 217 |
sample: { |
| 218 |
"idle_duration": "PT10M", |
| 219 |
"restart_on_idle": false, |
| 220 |
"stop_on_idle_end": true, |
| 221 |
"wait_timeout": "PT1H" |
| 222 |
} |
| 223 |
maintenance_settings: |
| 224 |
description: The maintenance settings of the task. |
| 225 |
returned: '' |
| 226 |
type: str |
| 227 |
sample: null |
| 228 |
mulitple_instances: |
| 229 |
description: Indicates the behaviour when starting a task that is already |
| 230 |
running. |
| 231 |
returned: '' |
| 232 |
type: int |
| 233 |
sample: 2 |
| 234 |
network_settings: |
| 235 |
description: The network settings of the task. |
| 236 |
returned: '' |
| 237 |
type: dict |
| 238 |
sample: { |
| 239 |
"id": null, |
| 240 |
"name": null |
| 241 |
} |
| 242 |
priority: |
| 243 |
description: The priority level of the task. |
| 244 |
returned: '' |
| 245 |
type: int |
| 246 |
sample: 7 |
| 247 |
restart_count: |
| 248 |
description: The number of times that the task will attempt to restart |
| 249 |
on failures. |
| 250 |
returned: '' |
| 251 |
type: int |
| 252 |
sample: 0 |
| 253 |
restart_interval: |
| 254 |
description: How long the Task Scheduler will attempt to restart the |
| 255 |
task. |
| 256 |
returned: '' |
| 257 |
type: str |
| 258 |
sample: PT15M |
| 259 |
run_only_id_idle: |
| 260 |
description: Whether the task will run if the computer is in an idle |
| 261 |
state. |
| 262 |
returned: '' |
| 263 |
type: bool |
| 264 |
sample: true |
| 265 |
run_only_if_network_available: |
| 266 |
description: Whether the task will run only when a network is available. |
| 267 |
returned: '' |
| 268 |
type: bool |
| 269 |
sample: false |
| 270 |
start_when_available: |
| 271 |
description: Whether the task can start at any time after its scheduled |
| 272 |
time has passed. |
| 273 |
returned: '' |
| 274 |
type: bool |
| 275 |
sample: false |
| 276 |
stop_if_going_on_batteries: |
| 277 |
description: Whether the task will be stopped if the computer begins to |
| 278 |
run on battery power. |
| 279 |
returned: '' |
| 280 |
type: bool |
| 281 |
sample: true |
| 282 |
use_unified_scheduling_engine: |
| 283 |
description: Whether the task will use the unified scheduling engine. |
| 284 |
returned: '' |
| 285 |
type: bool |
| 286 |
sample: false |
| 287 |
volatile: |
| 288 |
description: Whether the task is volatile. |
| 289 |
returned: '' |
| 290 |
type: bool |
| 291 |
sample: false |
| 292 |
wake_to_run: |
| 293 |
description: Whether the task will wake the computer when it is time to |
| 294 |
run the task. |
| 295 |
returned: '' |
| 296 |
type: bool |
| 297 |
sample: false |
| 298 |
state: |
| 299 |
description: Details on the state of the task |
| 300 |
returned: name is specified and task exists |
| 301 |
type: complex |
| 302 |
contains: |
| 303 |
last_run_time: |
| 304 |
description: The time the registered task was last run. |
| 305 |
returned: '' |
| 306 |
type: str |
| 307 |
sample: '2017-09-20T20:50:00' |
| 308 |
last_task_result: |
| 309 |
description: The results that were returned the last time the task was |
| 310 |
run. |
| 311 |
returned: '' |
| 312 |
type: int |
| 313 |
sample: 267009 |
| 314 |
next_run_time: |
| 315 |
description: The time when the task is next scheduled to run. |
| 316 |
returned: '' |
| 317 |
type: str |
| 318 |
sample: '2017-09-20T22:50:00' |
| 319 |
number_of_missed_runs: |
| 320 |
description: The number of times a task has missed a scheduled run. |
| 321 |
returned: '' |
| 322 |
type: int |
| 323 |
sample: 1 |
| 324 |
status: |
| 325 |
description: The status of the task, whether it is running, stopped, etc. |
| 326 |
returned: '' |
| 327 |
type: str |
| 328 |
sample: TASK_STATE_RUNNING |
| 329 |
task_exists: |
| 330 |
description: Whether the task at the folder exists. |
| 331 |
returned: name is specified |
| 332 |
type: bool |
| 333 |
sample: true |
| 334 |
triggers: |
| 335 |
description: A list of triggers. |
| 336 |
returned: name is specified and task exists |
| 337 |
type: list |
| 338 |
sample: [ |
| 339 |
{ |
| 340 |
"delay": "PT15M", |
| 341 |
"enabled": true, |
| 342 |
"end_boundary": null, |
| 343 |
"execution_time_limit": null, |
| 344 |
"id": null, |
| 345 |
"repetition": { |
| 346 |
"duration": null, |
| 347 |
"interval": null, |
| 348 |
"stop_at_duration_end": false |
| 349 |
}, |
| 350 |
"start_boundary": null, |
| 351 |
"type": "TASK_TRIGGER_BOOT" |
| 352 |
}, |
| 353 |
{ |
| 354 |
"days_of_month": "5,15,30", |
| 355 |
"enabled": true, |
| 356 |
"end_boundary": null, |
| 357 |
"execution_time_limit": null, |
| 358 |
"id": null, |
| 359 |
"months_of_year": "june,december", |
| 360 |
"random_delay": null, |
| 361 |
"repetition": { |
| 362 |
"duration": null, |
| 363 |
"interval": null, |
| 364 |
"stop_at_duration_end": false |
| 365 |
}, |
| 366 |
"run_on_last_day_of_month": true, |
| 367 |
"start_boundary": "2017-09-20T03:44:38", |
| 368 |
"type": "TASK_TRIGGER_MONTHLY" |
| 369 |
} |
| 370 |
] |
| 371 |
''' |