packer-plugin-windows-update
packer-plugin-windows-update copied to clipboard
Exception thrown while "Searching for Windows updates..."
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)