1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| ---
- name: Create Reboot Server Scheduler at every 5:00AM Sunday ON WINDOWS SERVER
hosts: "windows"
gather_facts: no
tasks:
- name: Create scheduled task
win_scheduled_task:
name: Reboot_Task
description: "Reboot every Sunday at 6:00 AM"
actions:
- path: "C:\\Windows\\System32\\shutdown.exe"
arguments: "/r /f /t 0"
triggers:
- type: weekly
weeks_interval: 1
days_of_week: SUNDAY
start_boundary: '2023-12-17T06:00:00'
enabled: yes
state: present
run_level: highest
run_as_user: SYSTEM
force: yes
username: System
password:
logon_type: SERVICE_ACCOUNT
disallow_start_if_on_batteries: false
- name: Get details of the scheduled task status
win_shell: Get-ScheduledTask -TaskName "Reboot_Task" | Select-Object TaskName,State
register: task_status
- name: Dispaly Task Info
debug:
var: task_status.stdout_lines
|