mgajda83 / PSWindowsUpdate

This module contain cmdlets to manage Windows Update Client.
MIT License
288 stars 25 forks source link

Object reference not set to an instance of an object. #27

Open jbne opened 2 months ago

jbne commented 2 months ago

I'm getting this error when trying to perform a Windows update using Packer to build a win11-23h2-ent VM in Azure:

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

This is a similar error to the packer-plugin-windows-update described in this issue that I recently opened, so maybe they are somewhat related - something that was never expected to be null is now null maybe?

https://github.com/rgl/packer-plugin-windows-update/issues/144

callworthp commented 2 months ago

I'm suddenly seeing this same error on a wide range of machines.

jbne commented 2 months ago

This issue is most likely caused by KB5040442, similar to the one I posted in the packer-plugin-windows-update issue. A workaround is to use a previous Windows version that does not include that update and/or exclude installing KB5040442 for now until there's a fix for it from Microsoft.

plao commented 2 months ago

I'm suddenly seeing this same error on a wide range of machines.

same issue for me...

callworthp commented 2 months ago

It's on multiple machines with multiple updates. It's not just one problematic update from Microsoft.

plao commented 2 months ago

Have a look here, I suppose, it's related...

https://learn.microsoft.com/en-us/windows/release-health/status-windows-11-23H2#the-june-2024-preview-update-might-impact-applications-using-windows-update-apis

HoffmannTom commented 2 months ago

It happens with all users I tried. system account, Administrator accounts ,normal account. Same error message as above.

callworthp commented 2 months ago

Updating PSWindowsUpdate to version 2.2.1.5 resolved the issue for me.

plao commented 2 months ago

Updating PSWindowsUpdate to version 2.2.1.5 resolved the issue for me.

Thanks a lot! I will try also and I will give here feedback!

plao commented 2 months ago

Updating PSWindowsUpdate to version 2.2.1.5 resolved the issue for me.

Seems to working, yes! Thanks a lot again ;-)

gen2k1 commented 2 months ago

Thanks, that also worked for me! :)