rgl / packer-plugin-windows-update

Packer plugin for installing Windows updates
Mozilla Public License 2.0
299 stars 71 forks source link

Filter windows updates doesn't work for WS2012 #108

Open tempora-mutantur opened 2 years ago

tempora-mutantur commented 2 years ago

Hi.

Using the following configuration:

  provisioner "windows-update" {
    search_criteria = "IsInstalled=0"
    filters = [
      "exclude:$_.Title -like '*Preview*'",
      "include:$true",
    ]
    update_limit = 25
  }

It fails with the following error

11:04:53 vsphere-clone.updates: ERROR: Element not found. (Exception from HRESULT: 0x80070490) 11:04:53 vsphere-clone.updates: ERROR: at , C:\Windows\Temp\packer-windows-update-elevated.ps1: line 60 11:04:53 vsphere-clone.updates: ERROR EXCEPTION: System.Runtime.InteropServices.COMException (0x80070490): Element not found. (Exception from HRESULT: 0x80070490) 11:04:53 vsphere-clone.updates: ERROR EXCEPTION: at System.Management.Automation.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, ComMethodDesc method, Object[] args, UInt32 argErr) 11:04:53 vsphere-clone.updates: ERROR EXCEPTION: at CallSite.Target(Closure , CallSite , ComObject , Object ) 11:04:53 vsphere-clone.updates: ERROR EXCEPTION: at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) 11:04:53 vsphere-clone.updates: ERROR EXCEPTION: at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) 11:04:53 vsphere-clone.updates: ERROR EXCEPTION: at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) 11:04:53 vsphere-clone.updates: ERROR EXCEPTION: at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 11:04:59 vsphere-clone.updates: ERROR: Element not found. (Exception from HRESULT: 0x80070490)

The same passes on WS2016

Thanks.

rgl commented 2 years ago

It seems the scheduled task was not returned from the API for some reason at https://github.com/rgl/packer-plugin-windows-update/blob/master/update/elevated-template.ps1#L60. But I have no idea why.

BTW, this was only tested with 2012R2. Maybe something needs to be changed to work with 2012, but I will not even try to do that, as that windows version is too old.