<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">win_updates</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible --version
ansible 2.4.0 (devel bfdf85e002) last updated 2017/07/26 15:31:51 (GMT -500)
  config file = None
  configured module search path = [u'/Users/tanner/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/tanner/projects/ansible.git/ansible/lib/ansible
  executable location = /Users/tanner/projects/ansible.git/ansible/bin/ansible
  python version = 2.7.10 (default, Feb  7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]"><pre class="notranslate"><code class="notranslate">$ ansible --version
ansible 2.4.0 (devel bfdf85e002) last updated 2017/07/26 15:31:51 (GMT -500)
  config file = None
  configured module search path = [u'/Users/tanner/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/tanner/projects/ansible.git/ansible/lib/ansible
  executable location = /Users/tanner/projects/ansible.git/ansible/bin/ansible
  python version = 2.7.10 (default, Feb  7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Management host macOS 10.12.5<br>
Managed host Windows 7</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">win_updates fails with  "error": "Exception from HRESULT: 0x8024402C",</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- name: Window updates
  win_updates:
    category_names:
      - SecurityUpdates
      - CriticalUpdates
      - UpdateRollups
  register: updates "><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">Window updates</span>
  <span class="pl-ent">win_updates</span>:
    <span class="pl-ent">category_names</span>:
      - <span class="pl-s">SecurityUpdates</span>
      - <span class="pl-s">CriticalUpdates</span>
      - <span class="pl-s">UpdateRollups</span>
  <span class="pl-ent">register</span>: <span class="pl-s">updates </span></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">Window updates would be applied for the category_names</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto"><a href="https://gist.github.com/basictheprogram/ccf2109f854d7f64658bbbe556108e93">https://gist.github.com/basictheprogram/ccf2109f854d7f64658bbbe556108e93</a></p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">Module: win_updates</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.1.0
  config file = /opt/uss/ansible/config/2.2.1.cfg
  configured module search path = ['/usr/share/ansible']"><pre class="notranslate"><code class="notranslate">ansible 2.2.1.0
  config file = /opt/uss/ansible/config/2.2.1.cfg
  configured module search path = ['/usr/share/ansible']
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">No special configuration options.</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">FROM: RHEL7<br>
TO: MS Windows Server 2012 R2 Standard</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto"><code class="notranslate">win_updates</code> module fails to complete.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="ansible -m win_updates -a &quot;state=search log_path=e:Scripts/ansible_win_updates.log&quot; -i inventory WindowsHosts.inv jumphost --tree out/ -vvv"><pre class="notranslate"><span class="pl-s">ansible -m win_updates -a "state=search log_path=e:Scripts/ansible_win_updates.log" -i inventory WindowsHosts.inv jumphost --tree out/ -vvv</span></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">Successful module run</p>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="jumphost | FAILED! =&gt; {
    &quot;changed&quot;: false,
    &quot;error&quot;: &quot;Exception from HRESULT: 0x80244019&quot;,
    &quot;failed&quot;: true,
    &quot;invocation&quot;: {
        &quot;module_name&quot;: &quot;win_updates&quot;
    },
    &quot;location&quot;: &quot;at DoWindowsUpdate, &lt;No file&gt;: line 72\r\nat &lt;ScriptBlock&gt;, &lt;No file&gt;: line 222&quot;
}"><pre class="notranslate"><code class="notranslate">jumphost | FAILED! =&gt; {
    "changed": false,
    "error": "Exception from HRESULT: 0x80244019",
    "failed": true,
    "invocation": {
        "module_name": "win_updates"
    },
    "location": "at DoWindowsUpdate, &lt;No file&gt;: line 72\r\nat &lt;ScriptBlock&gt;, &lt;No file&gt;: line 222"
}
</code></pre></div>
<p dir="auto">I was able to grab the <code class="notranslate">ps1</code> script that it had tried to run, and here are the lines where it appears to have errored out:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Function DoWindowsUpdate {
Param(
[string[]]$category_names=@(&quot;CriticalUpdates&quot;,&quot;SecurityUpdates&quot;,&quot;UpdateRollups&quot;),
[ValidateSet(&quot;installed&quot;, &quot;searched&quot;)]
[string]$state=&quot;installed&quot;,
[bool]$_ansible_check_mode=$false
)

$is_check_mode = $($state -eq &quot;searched&quot;) -or $_ansible_check_mode

$category_guids = $category_names | % { MapCategoryNameToGUID $_ }

$update_status = @{ changed = $false }

Write-DebugLog &quot;Creating Windows Update session...&quot;
$session = New-Object -ComObject Microsoft.Update.Session

Write-DebugLog &quot;Create Windows Update searcher...&quot;
$searcher = $session.CreateUpdateSearcher()

# OR is only allowed at the top-level, so we have to repeat base criteria inside
# FUTURE: change this to client-side filtered?
$criteriabase = &quot;IsInstalled = 0&quot;
$criteria_list = $category_guids | % { &quot;($criteriabase AND CategoryIDs contains '$_')&quot; }

$criteria = [string]::Join(&quot; OR &quot;, $criteria_list)

Write-DebugLog &quot;Search criteria: $criteria&quot;

Write-DebugLog &quot;Searching for updates to install in category IDs $category_guids...&quot;
$searchresult = $searcher.Search($criteria)

Write-DebugLog &quot;Creating update collection...&quot;"><pre class="notranslate"><code class="notranslate">Function DoWindowsUpdate {
Param(
[string[]]$category_names=@("CriticalUpdates","SecurityUpdates","UpdateRollups"),
[ValidateSet("installed", "searched")]
[string]$state="installed",
[bool]$_ansible_check_mode=$false
)

$is_check_mode = $($state -eq "searched") -or $_ansible_check_mode

$category_guids = $category_names | % { MapCategoryNameToGUID $_ }

$update_status = @{ changed = $false }

Write-DebugLog "Creating Windows Update session..."
$session = New-Object -ComObject Microsoft.Update.Session

Write-DebugLog "Create Windows Update searcher..."
$searcher = $session.CreateUpdateSearcher()

# OR is only allowed at the top-level, so we have to repeat base criteria inside
# FUTURE: change this to client-side filtered?
$criteriabase = "IsInstalled = 0"
$criteria_list = $category_guids | % { "($criteriabase AND CategoryIDs contains '$_')" }

$criteria = [string]::Join(" OR ", $criteria_list)

Write-DebugLog "Search criteria: $criteria"

Write-DebugLog "Searching for updates to install in category IDs $category_guids..."
$searchresult = $searcher.Search($criteria)

Write-DebugLog "Creating update collection..."
</code></pre></div>
<p dir="auto">And the relevant lines from the error log:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2017-06-08 11:29:31Z Arguments: System.Collections.Hashtable | out-string
2017-06-08 11:29:32Z OS Version: 
Major  Minor  Build  Revision
-----  -----  -----  --------
6      3      9600   0       



2017-06-08 11:29:32Z Running as user: JUMPHOST\ansible_boot
2017-06-08 11:29:32Z Powershell version: 
Name                           Value                                           
----                           -----                                           
PSVersion                      5.0.10586.117                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                         
BuildVersion                   10.0.10586.117                                  
CLRVersion                     4.0.30319.42000                                 
WSManStackVersion              3.0                                             
PSRemotingProtocolVersion      2.3                                             
SerializationVersion           1.1.0.1                                         



2017-06-08 11:29:32Z Starting scheduled job with args: 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
_ansible_debug                 False                                                                                                                                                                                                                                                                        
_ansible_version               2.2.1.0                                                                                                                                                                                                                                                                      
_ansible_diff                  False                                                                                                                                                                                                                                                                        
_ansible_syslog_facility       LOG_USER                                                                                                                                                                                                                                                                     
_ansible_check_mode            False                                                                                                                                                                                                                                                                        
_ansible_selinux_special_fs    {fuse, nfs, vboxsf, ramfs}                                                                                                                                                                                                                                                   
_ansible_module_name           win_updates                                                                                                                                                                                                                                                                  
state                          searched                                                                                                                                                                                                                                                                     
log_path                       e:/Scripts/ansible_win_updates.log                                                                                                                                                                                                                                           
_ansible_no_log                False                                                                                                                                                                                                                                                                        
_ansible_verbosity             3                                                                                                                                                                                                                                                                            



2017-06-08 11:29:32Z Registering scheduled job with args 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
ScheduledJobOption             {RunElevated}                                                                                                                                                                                                                                                                
ArgumentList                   {System.Collections.Hashtable}                                                                                                                                                                                                                                               
InitializationScript           ...                                                                                                                                                                                                                                                                          
Name                           ansible-win-updates                                                                                                                                                                                                                                                          
ScriptBlock                    ...                                                                                                                                                                                                                                                                          
ErrorAction                    Stop                                                                                                                                                                                                                                                                         



2017-06-08 11:29:32Z Starting scheduled job (PS4 method)
2017-06-08 11:29:32Z Waiting for job completion...
2017-06-08 11:29:34Z Scheduled job started with boundparms 
Name                           Value                                                                                   
----                           -----                                                                                   
_ansible_debug                 False                                                                                   
_ansible_version               2.2.1.0                                                                                 
_ansible_diff                  False                                                                                   
_ansible_syslog_facility       LOG_USER                                                                                
_ansible_check_mode            False                                                                                   
_ansible_selinux_special_fs    {fuse, nfs, vboxsf, ramfs}                                                              
_ansible_module_name           win_updates                                                                             
state                          searched                                                                                
log_path                       e:/Scripts/ansible_win_updates.log                                                      
_ansible_no_log                False                                                                                   
_ansible_verbosity             3                                                                                       


 and unboundargs 
2017-06-08 11:29:34Z Creating Windows Update session...
2017-06-08 11:29:34Z Create Windows Update searcher...
2017-06-08 11:29:34Z Search criteria: (IsInstalled = 0 AND CategoryIDs contains 'E6CF1350-C01B-414D-A61F-263D14D133B4') OR (IsInstalled = 0 AND CategoryIDs contains '0FA1201D-4330-4FA8-8AE9-B877473B6441') OR (IsInstalled = 0 AND CategoryIDs contains '28BC880E-0592-4CBF-8F95-C79B17911D5F')
2017-06-08 11:29:34Z Searching for updates to install in category IDs E6CF1350-C01B-414D-A61F-263D14D133B4 0FA1201D-4330-4FA8-8AE9-B877473B6441 28BC880E-0592-4CBF-8F95-C79B17911D5F...
2017-06-08 11:29:34Z Fatal exception: Exception from HRESULT: 0x80244019 at at DoWindowsUpdate, &lt;No file&gt;: line 72
at &lt;ScriptBlock&gt;, &lt;No file&gt;: line 222
2017-06-08 11:29:35Z Scheduled job completed with output: 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
error                          Exception from HRESULT: 0x80244019                                                                                                                                                                                                                                           
location                       at DoWindowsUpdate, &lt;No file&gt;: line 72...                                                                                                                                                                                                                                    
failed                         True                                                                                                                                                            ```"><pre class="notranslate"><code class="notranslate">2017-06-08 11:29:31Z Arguments: System.Collections.Hashtable | out-string
2017-06-08 11:29:32Z OS Version: 
Major  Minor  Build  Revision
-----  -----  -----  --------
6      3      9600   0       



2017-06-08 11:29:32Z Running as user: JUMPHOST\ansible_boot
2017-06-08 11:29:32Z Powershell version: 
Name                           Value                                           
----                           -----                                           
PSVersion                      5.0.10586.117                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                         
BuildVersion                   10.0.10586.117                                  
CLRVersion                     4.0.30319.42000                                 
WSManStackVersion              3.0                                             
PSRemotingProtocolVersion      2.3                                             
SerializationVersion           1.1.0.1                                         



2017-06-08 11:29:32Z Starting scheduled job with args: 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
_ansible_debug                 False                                                                                                                                                                                                                                                                        
_ansible_version               2.2.1.0                                                                                                                                                                                                                                                                      
_ansible_diff                  False                                                                                                                                                                                                                                                                        
_ansible_syslog_facility       LOG_USER                                                                                                                                                                                                                                                                     
_ansible_check_mode            False                                                                                                                                                                                                                                                                        
_ansible_selinux_special_fs    {fuse, nfs, vboxsf, ramfs}                                                                                                                                                                                                                                                   
_ansible_module_name           win_updates                                                                                                                                                                                                                                                                  
state                          searched                                                                                                                                                                                                                                                                     
log_path                       e:/Scripts/ansible_win_updates.log                                                                                                                                                                                                                                           
_ansible_no_log                False                                                                                                                                                                                                                                                                        
_ansible_verbosity             3                                                                                                                                                                                                                                                                            



2017-06-08 11:29:32Z Registering scheduled job with args 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
ScheduledJobOption             {RunElevated}                                                                                                                                                                                                                                                                
ArgumentList                   {System.Collections.Hashtable}                                                                                                                                                                                                                                               
InitializationScript           ...                                                                                                                                                                                                                                                                          
Name                           ansible-win-updates                                                                                                                                                                                                                                                          
ScriptBlock                    ...                                                                                                                                                                                                                                                                          
ErrorAction                    Stop                                                                                                                                                                                                                                                                         



2017-06-08 11:29:32Z Starting scheduled job (PS4 method)
2017-06-08 11:29:32Z Waiting for job completion...
2017-06-08 11:29:34Z Scheduled job started with boundparms 
Name                           Value                                                                                   
----                           -----                                                                                   
_ansible_debug                 False                                                                                   
_ansible_version               2.2.1.0                                                                                 
_ansible_diff                  False                                                                                   
_ansible_syslog_facility       LOG_USER                                                                                
_ansible_check_mode            False                                                                                   
_ansible_selinux_special_fs    {fuse, nfs, vboxsf, ramfs}                                                              
_ansible_module_name           win_updates                                                                             
state                          searched                                                                                
log_path                       e:/Scripts/ansible_win_updates.log                                                      
_ansible_no_log                False                                                                                   
_ansible_verbosity             3                                                                                       


 and unboundargs 
2017-06-08 11:29:34Z Creating Windows Update session...
2017-06-08 11:29:34Z Create Windows Update searcher...
2017-06-08 11:29:34Z Search criteria: (IsInstalled = 0 AND CategoryIDs contains 'E6CF1350-C01B-414D-A61F-263D14D133B4') OR (IsInstalled = 0 AND CategoryIDs contains '0FA1201D-4330-4FA8-8AE9-B877473B6441') OR (IsInstalled = 0 AND CategoryIDs contains '28BC880E-0592-4CBF-8F95-C79B17911D5F')
2017-06-08 11:29:34Z Searching for updates to install in category IDs E6CF1350-C01B-414D-A61F-263D14D133B4 0FA1201D-4330-4FA8-8AE9-B877473B6441 28BC880E-0592-4CBF-8F95-C79B17911D5F...
2017-06-08 11:29:34Z Fatal exception: Exception from HRESULT: 0x80244019 at at DoWindowsUpdate, &lt;No file&gt;: line 72
at &lt;ScriptBlock&gt;, &lt;No file&gt;: line 222
2017-06-08 11:29:35Z Scheduled job completed with output: 
Name                           Value                                                                                                                                                                                                                                                                        
----                           -----                                                                                                                                                                                                                                                                        
error                          Exception from HRESULT: 0x80244019                                                                                                                                                                                                                                           
location                       at DoWindowsUpdate, &lt;No file&gt;: line 72...                                                                                                                                                                                                                                    
failed                         True                                                                                                                                                            ```
</code></pre></div>