From 51b1cd061a5f46941ace9480164c2aebd1f29611 Mon Sep 17 00:00:00 2001
From: nitzmahone <mdavis@ansible.com>
Date: Tue, 27 Oct 2015 16:08:00 -0700
Subject: [PATCH] Strict-Mode fixes

Changes to missing member handling to support running top-level script under Strict-Mode v2 (as Ansible 2.0.0 does now)
---
 lib/ansible/modules/extras/windows/win_updates.ps1 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/ansible/modules/extras/windows/win_updates.ps1 b/lib/ansible/modules/extras/windows/win_updates.ps1
index d790aec6a29..3d5bc4c57c4 100644
--- a/lib/ansible/modules/extras/windows/win_updates.ps1
+++ b/lib/ansible/modules/extras/windows/win_updates.ps1
@@ -307,7 +307,7 @@ Function RunAsScheduledJob {
   $schedjob = Register-ScheduledJob @rsj_args
 
   # RunAsTask isn't available in PS3- fall back to a 2s future trigger
-  if($schedjob.RunAsTask) {
+  if($schedjob | Get-Member -Name RunAsTask) {
     Write-DebugLog "Starting scheduled job (PS4 method)"
     $schedjob.RunAsTask()
   }
@@ -337,8 +337,8 @@ Function RunAsScheduledJob {
   $sw = [System.Diagnostics.Stopwatch]::StartNew()
 
   # NB: output from scheduled jobs is delayed after completion (including the sub-objects after the primary Output object is available)
-  While (($job.Output -eq $null -or $job.Output.job_output -eq $null) -and $sw.ElapsedMilliseconds -lt 15000) {
-    Write-DebugLog "Waiting for job output to be non-null..."
+  While (($job.Output -eq $null -or -not $job.Output.Keys.Contains('job_output')) -and $sw.ElapsedMilliseconds -lt 15000) {
+    Write-DebugLog "Waiting for job output to populate..."
     Start-Sleep -Milliseconds 500
   }
 
@@ -351,7 +351,7 @@ Function RunAsScheduledJob {
       DebugOutput = $job.Debug
   }
 
-  If ($job.Output -eq $null -or $job.Output.job_output -eq $null) {
+  If ($job.Output -eq $null -or -not $job.Output.Keys.Contains('job_output')) {
       $ret.Output = @{failed = $true; msg = "job output was lost"}
   }
   Else {
@@ -404,7 +404,7 @@ $parsed_args = Parse-Args $args $true
 $parsed_args.psobject.properties | foreach -begin {$job_args=@{}} -process {$job_args."$($_.Name)" = $_.Value} -end {$job_args}
 
 # set the log_path for the global log function we injected earlier
-$log_path = $job_args.log_path
+$log_path = $job_args['log_path']
 
 Log-Forensics