From ef48448e4aff95d6afe21b10c2aeb931bff911c9 Mon Sep 17 00:00:00 2001
From: Jordan Borean <jborean93@gmail.com>
Date: Wed, 10 Jan 2018 10:23:04 +1000
Subject: [PATCH] win_scheduled_task_stat: correctly return values from nested
 com values (#34671)

---
 .../modules/windows/win_scheduled_task_stat.ps1  |  3 ++-
 .../modules/windows/win_scheduled_task_stat.py   | 16 ++++++++++++----
 .../win_scheduled_task_stat/tasks/main.yml       |  6 ++++++
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/lib/ansible/modules/windows/win_scheduled_task_stat.ps1 b/lib/ansible/modules/windows/win_scheduled_task_stat.ps1
index c35d509120b..f866a836a64 100644
--- a/lib/ansible/modules/windows/win_scheduled_task_stat.ps1
+++ b/lib/ansible/modules/windows/win_scheduled_task_stat.ps1
@@ -76,7 +76,7 @@ Function Get-PropertyValue($task_property, $com, $property) {
         $com_values = @{}
         $properties = Get-Member -InputObject $raw_value -MemberType Property | % {
             $com_value = Get-PropertyValue -task_property $property -com $raw_value -property $_.Name
-            $com_values.$property = $com_value
+            $com_values.$($_.Name) = $com_value
         }
 
         return ,$com_values
@@ -318,3 +318,4 @@ if ($name -ne $null) {
 $result = Convert-DictToSnakeCase -dict $result
 
 Exit-Json -obj $result
+
diff --git a/lib/ansible/modules/windows/win_scheduled_task_stat.py b/lib/ansible/modules/windows/win_scheduled_task_stat.py
index b95f6a40f4f..4959aceab3f 100644
--- a/lib/ansible/modules/windows/win_scheduled_task_stat.py
+++ b/lib/ansible/modules/windows/win_scheduled_task_stat.py
@@ -219,7 +219,10 @@ settings:
       returned: ''
       type: dictionary
       sample: {
-          "idle_settings": "PT1H"
+          "idle_duration": "PT10M",
+          "restart_on_idle": false,
+          "stop_on_idle_end": true,
+          "wait_timeout": "PT1H"
       }
     maintenance_settings:
       description: The maintenance settings of the task.
@@ -237,7 +240,8 @@ settings:
       returned: ''
       type: dictionary
       sample: {
-          "network_settings": null
+          "id": null,
+          "name": null
       }
     priority:
       description: The priority level of the task.
@@ -343,7 +347,9 @@ triggers:
           "execution_time_limit": null,
           "id": null,
           "repetition": {
-              "repetition": false
+              "duration": null,
+              "interval": null,
+              "stop_at_duration_end": false
           },
           "start_boundary": null,
           "type": "TASK_TRIGGER_BOOT"
@@ -357,7 +363,9 @@ triggers:
           "months_of_year": "june,december",
           "random_delay": null,
           "repetition": {
-              "repetition": false
+              "duration": null,
+              "interval": null,
+              "stop_at_duration_end": false
           },
           "run_on_last_day_of_month": true,
           "start_boundary": "2017-09-20T03:44:38",
diff --git a/test/integration/targets/win_scheduled_task_stat/tasks/main.yml b/test/integration/targets/win_scheduled_task_stat/tasks/main.yml
index d8795e71f25..fe0b02084fa 100644
--- a/test/integration/targets/win_scheduled_task_stat/tasks/main.yml
+++ b/test/integration/targets/win_scheduled_task_stat/tasks/main.yml
@@ -114,11 +114,17 @@
     - stat_task_present.triggers|count == 2
     - stat_task_present.triggers[0].delay == "PT15M"
     - stat_task_present.triggers[0].type == "TASK_TRIGGER_BOOT"
+    - stat_task_present.triggers[0].repetition.stop_at_duration_end == False
+    - stat_task_present.triggers[0].repetition.duration == None
+    - stat_task_present.triggers[0].repetition.interval == None
     - stat_task_present.triggers[1].days_of_month == "5,15,30"
     - stat_task_present.triggers[1].months_of_year == "june,december"
     - stat_task_present.triggers[1].run_on_last_day_of_month == True
     - stat_task_present.triggers[1].start_boundary == "2017-09-20T03:44:38"
     - stat_task_present.triggers[1].type == "TASK_TRIGGER_MONTHLY"
+    - stat_task_present.triggers[1].repetition.stop_at_duration_end == False
+    - stat_task_present.triggers[1].repetition.duration == None
+    - stat_task_present.triggers[1].repetition.interval == None
 
 - name: change principal to system account so it will run in the next step
   win_scheduled_task: