rgl / packer-plugin-windows-update

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

Exception thrown while "Searching for Windows updates..." #144

Open jbne opened 1 month ago

jbne commented 1 month ago

I'm getting an error when the builder is in the "Searching for Windows updates..." step. I was able to successfully perform Windows updates using this plugin yesterday and earlier today, my configuration hasn't functionally changed since then so not sure what could be causing this.   Here's the relevant bits, let me know if more info is needed to diagnose the issue:

packer {
  required_plugins {
    azure = {
      source  = "github.com/hashicorp/azure"
      version = "~> 2"
    }

    windows-update = {
      version = "0.16.0"
      source = "github.com/rgl/windows-update"
    }
  }
}

...

Using an Azure managed image as the base:

image_publisher               = "MicrosoftWindowsDesktop"
image_offer                       = "Windows-11"
image_sku                         = "win11-23h2-ent"

...

This is the first step in my build:

provisioner "windows-update" {
  pause_before    = "60s"
  search_criteria = "IsInstalled=0"
  filters = [
    "exclude:$_.Title -like '*Preview*'",
    "exclude:$_.InstallationBehavior.CanRequestUserInput",
    "include:$true"
  ]
  restart_timeout = "120m"
}

Also tried with no params, same error:

provisioner "windows-update" {
}

...

Here are the logs:

2024-07-09T17:21:26-07:00: ==> azure-arm.autogenerated_1: Waiting for WinRM to become available...
2024-07-09T17:21:36-07:00:     azure-arm.autogenerated_1: WinRM connected.
2024-07-09T17:21:36-07:00: ==> azure-arm.autogenerated_1: Connected to WinRM!
2024-07-09T17:21:36-07:00: ==> azure-arm.autogenerated_1: Pausing 1m0s before the next provisioner...
2024-07-09T17:22:36-07:00: ==> azure-arm.autogenerated_1: Uploading the Windows update elevated script...
2024-07-09T17:22:38-07:00: ==> azure-arm.autogenerated_1: Uploading the Windows update check for reboot required elevated script...
2024-07-09T17:23:04-07:00: ==> azure-arm.autogenerated_1: Uploading the Windows update script...
2024-07-09T17:23:07-07:00: ==> azure-arm.autogenerated_1: Running Windows update...
2024-07-09T17:23:15-07:00:     azure-arm.autogenerated_1: Searching for Windows updates...
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR: You cannot call a method on a null-valued expression.
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR: at <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: line 190
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR: at <ScriptBlock>, <No file>: line 1
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR EXCEPTION: System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR EXCEPTION:    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-09T17:23:25-07:00:     azure-arm.autogenerated_1: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
rolandsallaberger commented 1 month ago

i have the same issue today

raptorrico commented 1 month ago

We also have the same issue with builds today, running 0.16

I'm going to try using version 0.15

xenadmin commented 1 month ago

We have the same error with Windows 11 23H2 since today. Already tested plugin version 0.15 and 0.16. The only change was Microsoft Patchday and therefore changes in the Azure marketplace images. I suspect the change there ;-(

RyansGitrepos commented 1 month ago

Same issue here! 0.15 and 0.16 also not working! We are using the Windows 11 23H2 AVD image without office. Using the Azure Marketplace.

tomvo12 commented 1 month ago

Same issue here! We are not able to create windows images anymore. Is it possible to prioritize PR#145 to get us back in business asap? thanks in advance

florian-ried commented 1 month ago

We are encountering the same issue with versions 0.15 and 0.16 as previously reported by other users. We're using the Windows 11 23H2 AVD image without Office from the Azure Marketplace.

We would greatly appreciate it if PR #145 could be prioritized to help us resolve this issue as soon as possible.

jbne commented 1 month ago

Another interesting bit is I also tried using the PSWindowsUpdate Powershell module and it seems to hit a very similar null reference issue? Maybe not related, but it would be quite a coincidence.

2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1: Install-WindowsUpdate : Something goes wrong: Update for Windows Security platform antimalware platform - KB5007651
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1: (Version 1.0.2402.27001); Object reference not set to an instance of an object.
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1: At C:\Windows\Temp\script-668de296-dc4e-939c-b1ea-098a3fa74e58.ps1:18 char:1
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1: + Install-WindowsUpdate -AcceptAll -AutoReboot
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1:     + CategoryInfo          : CloseError: (:) [Get-WindowsUpdate], Exception
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1:     + FullyQualifiedErrorId : Debug,PSWindowsUpdate.GetWindowsUpdate
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1:
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1: Script exited with non-zero exit status: 1. Allowed exit codes are: [0]
2024-07-09T18:24:25-07:00: ==> azure-arm.autogenerated_1: Step "StepProvision" failed
KarsonAlford commented 1 month ago

Same here.

My Server 2016 and Server 2022 image templates are able to be built and they include the windows update steps in them.

rgl commented 1 month ago

please try https://github.com/rgl/packer-plugin-windows-update/releases/tag/v0.16.1

xenadmin commented 1 month ago

@rgl Why did you close the issue without feedback? Please reopen it. I just tested 0.16.1. Issue persists for us, Still can't build Windows 11 23H2 images with Packer on Azure. Here you can see we switched to 0.16.1: grafik And here is the log from the latest try: grafik And here is the log from 0.16.1:

2024-07-10T21:26:41.2645798Z 2024-07-10T23:26:41+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update elevated script...
2024-07-10T21:26:44.8306438Z 2024-07-10T23:26:44+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update check for reboot required elevated script...
2024-07-10T21:26:48.1812786Z 2024-07-10T23:26:48+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update script...
2024-07-10T21:26:54.8298721Z 2024-07-10T23:26:54+02:00: ==> azure-arm.win11-23h2-avd: Running Windows update...
2024-07-10T21:27:01.1640969Z 2024-07-10T23:27:01+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T21:27:15.7423994Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:27:15.7425625Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 204
2024-07-10T21:27:15.7440017Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T21:27:15.7446241Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.PropertyNotFoundException: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:27:15.7454102Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T21:27:15.7462631Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T21:27:15.7477893Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:15.7485140Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:15.7495559Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:15.7510249Z 2024-07-10T23:27:15+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:26.2668219Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T21:27:26.2678767Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:27:26.2686797Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 204
2024-07-10T21:27:26.2697215Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T21:27:26.2710312Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.PropertyNotFoundException: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:27:26.2727000Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T21:27:26.2728749Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T21:27:26.2747017Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:26.2753791Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:26.2757354Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:26.2769411Z 2024-07-10T23:27:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:36.7485829Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T21:27:36.7501690Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:27:36.7507484Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 204
2024-07-10T21:27:36.7517096Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T21:27:36.7537694Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.PropertyNotFoundException: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:27:36.7542175Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T21:27:36.7554188Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T21:27:36.7567691Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:36.7576823Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:36.7586589Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:36.7601194Z 2024-07-10T23:27:36+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:27:47.9964093Z 2024-07-10T23:27:47+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T21:28:07.5800306Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:28:07.5808781Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 204
2024-07-10T21:28:07.5825641Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T21:28:07.5840906Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.PropertyNotFoundException: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:28:07.5857351Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T21:28:07.5870109Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T21:28:07.5880796Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:28:07.5891822Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:28:07.6002361Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:28:07.6006295Z 2024-07-10T23:28:07+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:28:18.7199900Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T21:28:18.7214416Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:28:18.7221923Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 204
2024-07-10T21:28:18.7232958Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T21:28:18.7245299Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.PropertyNotFoundException: Die Eigenschaft "CanRequestUserInput" wurde fr dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist.
2024-07-10T21:28:18.7248308Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T21:28:18.7254251Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T21:28:18.7273448Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:28:18.7284166Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:28:18.7287381Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:28:18.7303519Z 2024-07-10T23:28:18+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T21:28:23.7340581Z 2024-07-10T23:28:23+02:00: ==> azure-arm.win11-23h2-avd: Provisioning step had errors: Running the cleanup provisioner, if present...
2024-07-10T21:28:23.7535823Z 2024-07-10T23:28:23+02:00: ==> azure-arm.win11-23h2-avd: 
2024-07-10T21:28:23.7537843Z ==> azure-arm.win11-23h2-avd: Deleting Virtual Machine deployment and its attached resources...

EDIT I just saw that the error differs from my try with 0.15.0 so here is the 0.15.0 log from this afternoon for reference:

2024-07-10T12:31:31.2724002Z 2024-07-10T14:31:31+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update elevated script...
2024-07-10T12:31:34.6874255Z 2024-07-10T14:31:34+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update check for reboot required elevated script...
2024-07-10T12:31:37.9283571Z 2024-07-10T14:31:37+02:00: ==> azure-arm.win11-23h2-avd: Uploading the Windows update script...
2024-07-10T12:31:44.2799401Z 2024-07-10T14:31:44+02:00: ==> azure-arm.win11-23h2-avd: Running Windows update...
2024-07-10T12:31:50.4765948Z 2024-07-10T14:31:50+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T12:32:40.0877717Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:32:40.0879494Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 190
2024-07-10T12:32:40.0884896Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T12:32:40.0890740Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.RuntimeException: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:32:40.0907948Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T12:32:40.0910495Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T12:32:40.0924606Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:32:40.0944427Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:32:40.0949138Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:32:40.0958635Z 2024-07-10T14:32:40+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:32:51.5978548Z 2024-07-10T14:32:51+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T12:33:11.1656053Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:33:11.1664742Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 190
2024-07-10T12:33:11.1673368Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T12:33:11.1683252Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.RuntimeException: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:33:11.1693083Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T12:33:11.1701205Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T12:33:11.1710413Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:11.1727334Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:11.1735428Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:11.1745727Z 2024-07-10T14:33:11+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:22.2720394Z 2024-07-10T14:33:22+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T12:33:26.9769365Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:33:26.9778779Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 190
2024-07-10T12:33:26.9786071Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T12:33:26.9797769Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.RuntimeException: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:33:26.9819020Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T12:33:26.9822391Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T12:33:26.9832673Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:26.9840791Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:26.9853472Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:26.9863505Z 2024-07-10T14:33:26+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:38.2360797Z 2024-07-10T14:33:38+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T12:33:42.7897834Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:33:42.7905129Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 190
2024-07-10T12:33:42.7912811Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T12:33:42.7922926Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.RuntimeException: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:33:42.7943156Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T12:33:42.7950803Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T12:33:42.7964747Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:42.7975511Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:42.7995594Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:42.8002204Z 2024-07-10T14:33:42+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:33:54.1809861Z 2024-07-10T14:33:54+02:00:     azure-arm.win11-23h2-avd: Searching for Windows updates...
2024-07-10T12:34:03.7394170Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:34:03.7403348Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: Zeile 190
2024-07-10T12:34:03.7409860Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR: bei <ScriptBlock>, <Keine Datei>: Zeile 1
2024-07-10T12:34:03.7428063Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION: System.Management.Automation.RuntimeException: Es ist nicht m”glich, eine Methode fr einen Ausdruck aufzurufen, der den NULL hat.
2024-07-10T12:34:03.7431223Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2024-07-10T12:34:03.7439534Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2024-07-10T12:34:03.7454481Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:34:03.7458352Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:34:03.7473069Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:34:03.7487631Z 2024-07-10T14:34:03+02:00:     azure-arm.win11-23h2-avd: ERROR EXCEPTION:    bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2024-07-10T12:34:08.7606473Z 2024-07-10T14:34:08+02:00: ==> azure-arm.win11-23h2-avd: Provisioning step had errors: Running the cleanup provisioner, if present...
2024-07-10T12:34:08.7618472Z 2024-07-10T14:34:08+02:00: ==> azure-arm.win11-23h2-avd: 
2024-07-10T12:34:08.7620365Z ==> azure-arm.win11-23h2-avd: Deleting Virtual Machine deployment and its attached resources...
brmcmill commented 1 month ago

We're seeing this with Custom Image Templates and AVD customers as well.

Dellson commented 1 month ago

I confirm that the newest update didn't help. I am getting the same exception as @xenadmin. The issue happens only for Windows 11 / Windows 11 IP after yesterday's monthly Windows Update release.

    azure-arm.exact-ta-template: Searching for Windows updates...
    azure-arm.exact-ta-template: ERROR: The property 'CanRequestUserInput' cannot be found on this object. Verify that the property exists.
    azure-arm.exact-ta-template: ERROR: at <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: line 204
    azure-arm.exact-ta-template: ERROR: at <ScriptBlock>, <No file>: line 1
    azure-arm.exact-ta-template: ERROR EXCEPTION: System.Management.Automation.PropertyNotFoundException: The property 'CanRequestUserInput' cannot be found on this object. Verify that the property exists.
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Dellson commented 1 month ago

I applied the newest release (v0.16.3). The 'CanRequestUserInput' issue is gone, but there is a new one. The plugin found an update that seems to be invalid, as it is empty and was allegedly created on the Unix epoch time.

    azure-arm.exact-ta-template: Searching for Windows updates...
    azure-arm.exact-ta-template: Found Windows update (1970-01-01; 0 MB):
    azure-arm.exact-ta-template: ERROR: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))
    azure-arm.exact-ta-template: ERROR: at <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: line 216
    azure-arm.exact-ta-template: ERROR: at <ScriptBlock>, <No file>: line 1
    azure-arm.exact-ta-template: ERROR EXCEPTION: System.Runtime.InteropServices.COMException (0x8002802B): Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.ComInterop.ComRuntimeHelpers.GetITypeInfoFromIDispatch(IDispatch dispatch, Boolean throwIfMissingExpectedTypeInfo)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.ComInterop.IDispatchComObject.EnsureScanDefinedMethods()
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.ComInterop.IDispatchComObject.System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(Expression parameter)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Dynamic.DynamicMetaObject.Create(Object value, Expression expression)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
    azure-arm.exact-ta-template: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
rgl commented 1 month ago

please try https://github.com/rgl/packer-plugin-windows-update/releases/tag/v0.16.4. it now ignores updates that do not have a title.

Ruthhl3ss commented 1 month ago

please try https://github.com/rgl/packer-plugin-windows-update/releases/tag/v0.16.4. it now ignores updates that do not have a title.

Hello,

I tried to update the packer module to 0.16.4 but it does not find any updates anymore:

image

In previous version it always finds updates, example:

image

So, I think it doesn't find the updates anymore.

xenadmin commented 1 month ago

I can confirm what @Ruthhl3ss says, it doesn't find updates anymore, it has always found Defender updates before.

jbne commented 1 month ago

My guess is something in the latest Windows 11 build 22631.3880.240704 released on 07/09 broke WSUS or some other component used by Windows Update Agent, resulting in updates being correctly picked up by the Windows Update Agent but having $null fields. Or something in between those layers broke as well that result in this behavior, not entirely sure at this point.

A workaround that worked for me was pinning Windows version to the previous 22631.3737.240607. Not the best thing, but at least it might fix the issue for some of you who don't necessarily care about using the latest version out of the box. The updates from KB5040442 are picked up and installed correctly on the previous version anyway, which seems to be the main difference across the latest and the previous version.

EDIT: I spoke too soon, the issue appears again after KB5040442 is installed. So maybe excluding that update would work.

jbne commented 1 month ago

I tried excluding KB5040442, that worked fine. Something about KB5040442 is breaking the COM interface, so it's not an issue that can be fixed in this plugin.

But maybe having an appropriate error message that indicates a break in behavior with Microsoft.Update.Session would be a good idea.

xenadmin commented 1 month ago

@jbne Did you try that with plugin version 0.16.4? Excluding KB5040442 should break nothing, as the Azure marketplace images are already on the latest CU, so we should be able to exclude that without any downsides at all, do you agree?

jbne commented 1 month ago

No I tried that with 0.16, haven't updated yet. I agree, other than not having the updates from KB5040442 most users wouldn't be affected by excluding it.

alkurdy commented 1 month ago

Jsut an fyi: https://community.automox.com/industry-discussion-143/windows-11-updates-api-was-secretly-changed-here-s-what-it-broke-how-to-fix-it-2507

jbne commented 1 month ago

@jbne Did you try that with plugin version 0.16.4? Excluding KB5040442 should break nothing, as the Azure marketplace images are already on the latest CU, so we should be able to exclude that without any downsides at all, do you agree?

re: this, tried with 0.16.4 and it worked fine when including a filter this way (as well as setting the image_version to the previous instead of latest):

image_version = "22631.3737.240607" # "latest" is the default

provisioner "windows-update" {
    filters = [
      "exclude:$_.Title -like '*KB5040442*'",
      "include:$true"
    ]
  }
rgl commented 1 month ago

Jsut an fyi: https://community.automox.com/industry-discussion-143/windows-11-updates-api-was-secretly-changed-here-s-what-it-broke-how-to-fix-it-2507

At https://learn.microsoft.com/en-sg/answers/questions/1791668/powershell-command-outputting-system-comobject-on there seems to be more details.

xenadmin commented 1 month ago

@jbne tried your filter, my pipeline still doesn't install any windows updates.

alucenx commented 1 month ago

@jbne tried your filter, my pipeline still doesn't install any windows updates.

this bit "type": "PowerShell", "name": "SetUUSFeatureOverride", "inline": [ "$uusKey = \"HKLM:\SYSTEM\CurrentControlSet\Control\FeatureManagement\Overrides\4\1931709068\"", "if (Test-Path $uusKey) {", " if ((Get-ItemProperty -Path $uusKey -Name 'EnabledState').EnabledState -ne 1) {", " Set-ItemProperty -Path $uusKey -Name 'EnabledState' -Value 1 -Force", " $host.UI.WriteErrorLine(\"UUS Feature override (1931709068) EnabledState changed to 1\")", " }", "}" ], "runAsSystem": true, "runElevated": true

combined with "type": "WindowsUpdate", "searchCriteria": "IsInstalled=0", "filters": [ "exclude:$.Title -like 'KB5040442'", "exclude:$.Title -like 'Preview'", "include:$true" ], "updateLimit": 25 managed to work for me, successfuly deployed via azure image builder, not sure if it will help

xenadmin commented 1 month ago

@alucenx Maybe a code block next time? Pretty hard to read ;-) EDIT: I'm testing your approach as we speak. Will report back in a few hours!

alucenx commented 1 month ago

@alucenx Maybe a code block next time? Pretty hard to read ;-) Yeah, apologies, 3 AM for me when I commented, brain was fried a bit =)

HenryGelderbloem commented 1 month ago

I have this issue and I'd rather not filter out the KB so I have escalated it to the Windows team to investigate as it is clear that it isn't an issue with this packer plugin.

jbne commented 1 month ago

@jbne tried your filter, my pipeline still doesn't install any windows updates.

Ahh that might be because you're still using the latest image version, you would have to roll back to the previous using image_version - sorry I didn't include that in my comment originally 😅 I updated it to reflect that. That exclusion filter doesn't retroactively work when the KB update is already baked into the image, which is the case with latest.

Though it sounds like that piece posted by @alkurdy might fix latest, which is what @alucenx tried. You probably don't need the filter in that case.

rgl commented 1 month ago

please try https://github.com/rgl/packer-plugin-windows-update/releases/tag/v0.16.7

it includes the workaround described at https://learn.microsoft.com/en-sg/answers/questions/1791668/powershell-command-outputting-system-comobject-on and at The June 2024 preview update might impact applications using Windows Update APIs.

svetecs commented 1 month ago

I'm running my packer build with 0.16.7, using:

provisioner "windows-update" { pause_before = "10m" searchcriteria = "IsInstalled=0" filters = [ "exclude:$.Title -like 'Preview'", "include:$true", ] }

...and it looks better:

image

ethancameron commented 1 month ago

I still see the issues with version 0.16.7 using the latest win11-23h2-avd image from Microsoft:

image

svetecs commented 1 month ago

I'm using win11-23h2-pro build 22631.3880.240704

rgl commented 1 month ago

I still see the issues with version 0.16.7 using the latest win11-23h2-avd image from Microsoft:

image

the workaround didn't work there. I'm afraid you/we have to wait for microsoft to fix this known issue as described in the article: The June 2024 preview update might impact applications using Windows Update APIs.

xenadmin commented 1 month ago

@rgl Thank you for the link! Now we all know this is a Know issue and that we have to wait, sadly.

ethancameron commented 1 month ago

I still see the issues with version 0.16.7 using the latest win11-23h2-avd image from Microsoft:

image

I was able to get it working by adding the line:

pause_before = "10m"

Without that line, it does not work for me.

svetecs commented 1 month ago

As an FYI, I always have had that 'pause before' in the WU task so I can't say if that's what corrected it for me.

Edit: Strange. My PRO builds were working fine. I've ran a few packer builds of 11 23h3 pro without issue, then my latest one give me:

ERROR EXCEPTION: System.Management.Automation.RuntimeException: the windows update api is in an invalid state. see https://github.com/rgl/packer-plugin-windows-update/issues/144.

alucenx commented 1 month ago

As an FYI, I always have had that 'pause before' in the WU task so I can't say if that's what corrected it for me.

Edit: Strange. My PRO builds were working fine. I've ran a few packer builds of 11 23h3 pro without issue, then my latest one give me:

ERROR EXCEPTION: System.Management.Automation.RuntimeException: the windows update api is in an invalid state. see #144.

Try using a fixed build (ex: i use 22631.3737.240611, ent) and exclude:$_.Title -like 'KB5040442' Have had no issues since I started doing that on enterprise builds

svetecs commented 1 month ago

Try using a fixed build (ex: i use 22631.3737.240611, ent) and exclude:$_.Title -like 'KB5040442' Have had no issues since I started doing that on enterprise builds

I re-ran my PRO build right after it errored out and updates sailed through without issue. I haven't excluded 5040442. I'm still using the provisioner like I posted above. I've done other builds after that and so far, none have failed.

xenadmin commented 1 month ago

@alucenx When you start from an older build like 22631.3737.240607 and exclude KB5040442, that final image delivered to the customer will never reach 22631.3880.240704 and therefore will be vulnerable, won't it? Or do I misunderstand your approach?

Today, I'll try the following settings:

inistor commented 1 month ago

In my case, I had the error (System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression) using the plugin version v0.16.0 and Windows 11 ISO 23H2.7, build 77827, Jun 2024.

After upgrading to v0.16.7, it works fin with both:

My plugin configuration is basic:

  provisioner "windows-update" {
    pause_before = "30s"
  }

I don't believe the pause is needed anymore - in the past, with v0.16.0, is sometimes worked so I presumed that a pause might help - though in most cases (say 4 out of 5) it failed with the same System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression error.

HenryGelderbloem commented 1 month ago

Microsoft have fixed the underlying cause of the issue in KB5040527 https://support.microsoft.com/en-gb/topic/july-25-2024-kb5040527-os-builds-22621-3958-and-22631-3958-preview-de3e1e24-0c07-4210-9777-8e03a1446bae

jbne commented 1 month ago

Thanks @HenryGelderbloem, I'll be testing out with the following today:

windows-update = {
      version = "0.16.7"
      source = "github.com/rgl/windows-update"
    }

image_publisher = "MicrosoftWindowsDesktop"
image_offer = "Windows-11"
image_sku = "win11-23h2-ent"
image_version = "latest"

provisioner "windows-update" {
  restart_timeout = "5m"
}
jbne commented 1 month ago

image_version = "latest" did not work for me, but using the previous Windows version image_version = "22631.3737.240607" installs all updates properly without having to filter out the problematic update KB5040442. I think KB5040527 should be included in next month's Windows build, at which point using image_version = "latest" should hopefully work.