rgl / packer-plugin-windows-update

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

Duplicate SQL Server Updates found when running escalated Windows Update script resulting in HRESULT: 0x80240013 #131

Closed stuartp44 closed 8 months ago

stuartp44 commented 1 year ago

I have noted on our regular builds that there is a strange issue occurs when I approve an update from the WSUS server, targeting SQL Server, that makes ghost duplicate updates appear (The ONLY difference, which I can see, is dates) see below. I can replicate this perfectly when I run the packer-windows-update-elevated.ps1 locally and logged into the system exact same system that outputted the below log. What's makes it even more confusing, if I run packer-windows-update.ps1 in the same machine (of course without running the packer-windows-update-elevated.ps1 first) it installs all updates fine and most importantly without any ghost updates. It ONLY appears if you run the packer-windows-update-elevated.ps1 script, which as we all know, creates a task in the context of the user and executes it.

vsphere-clone.: Searching for Windows updates... vsphere-clone.: Found Windows update (2023-03-05; 465.15 MB): Security Update for SQL Server 2019 RTM GDR (KB5021125) vsphere-clone.: Found Windows update (2023-08-08; 56.6 MB): Windows Malicious Software Removal Tool x64 - v5.116 (KB890830) vsphere-clone.: Found Windows update (2023-08-14; 751.04 MB): SQL Server 2019 RTM Cumulative Update (CU) 22 KB5027702 vsphere-clone.: Found Windows update (2023-03-24; 676.8 MB): SQL Server Management Studio 18.12.1 vsphere-clone.: Found Windows update (2023-02-15; 741.62 MB): Security Update for SQL Server 2019 RTM CU (KB5021124) vsphere-clone.: Found Windows update (2023-08-23; 751.04 MB): SQL Server 2019 RTM Cumulative Update (CU) 22 KB5027702 vsphere-clone.: Downloading Windows updates (6 updates; 3442.27 MB)... vsphere-clone.: ERROR: Exception from HRESULT: 0x80240013 vsphere-clone.: ERROR: at , C:\Windows\Temp\packer-windows-update.ps1: line 231 vsphere-clone.: ERROR: at , : line 1 vsphere-clone.: ERROR EXCEPTION: System.Runtime.InteropServices.COMException (0x80240013): Exception from HRESULT: 0x80240013 vsphere-clone.: ERROR EXCEPTION: at System.Management.Automation.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, ComMethodDesc method, Object[] args, UInt32 argErr) vsphere-clone.: ERROR EXCEPTION: at CallSite.Target(Closure , CallSite , ComObject ) vsphere-clone.: ERROR EXCEPTION: at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) vsphere-clone.: ERROR EXCEPTION: at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) vsphere-clone.: ERROR EXCEPTION: at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame) vsphere-clone.: ERROR EXCEPTION: at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

image

Packer Version - 1.9.1 Windows Update Plugin - 0.14.1

I have created a small behaviour patch for the Powershell script to try and stop it trying to install two. PR to follow!

This is on a clean build, from scratch, every time

rgl commented 1 year ago

I never seen this behavior before. And I'm afraid I have no idea what causes it or how to fix it. Maybe the logs show something useful.

rgl commented 8 months ago

@stuartp44 in your case from above, it seems the two titles are not exactly the same (KB5027702 vs KB502770):

vsphere-clone.: Found Windows update (2023-08-14; 751.04 MB): SQL Server 2019 RTM Cumulative Update (CU) 22 KB5027702
vsphere-clone.: Found Windows update (2023-08-23; 751.04 MB): SQL Server 2019 RTM Cumulative Update (CU) 22 KB502770

Was that somehow a copy&paste typo?

PS: oh it was. the screenshots have the same KB number!

stuartp44 commented 8 months ago

Yes, sorry it is the same, didnt manage to capture all data from the console. Sorry, my bad! Manually modified to match actual error