mgajda83 / PSWindowsUpdate

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

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

Open gen2k1 opened 2 months ago

gen2k1 commented 2 months ago

Since several weeks I am not able anymore to install new updates. It always fails with the error: 'Object reference not set to an instance of an object'. Does anyone know how to fix this. I have uninstalled and reinstalled PSWindowsUpdate but without success.

As an example todays full verbose output is:

VERBOSE: PC (18.05.2024 09:37:48): Connecting to Microsoft Update server. Please wait... VERBOSE: Found [1] Updates in pre search criteria VERBOSE: Found [1] Updates in post search criteria Get-WindowsUpdate: Something goes wrong: Cumulative Update for Windows 11 Insider Preview (10.0.22635.3640) (KB5037867); Object reference not set to an instance of an object. Get-WindowsUpdate: Something goes wrong: Cumulative Update for Windows 11 Insider Preview (10.0.22635.3640) (KB5037867); Object reference not set to an instance of an object.

X ComputerName Result KB Size Title


VERBOSE: Accepted [0] Updates ready to Download VERBOSE: Downloaded [0] Updates ready to Install VERBOSE: Installed [0] Updates

GKilsgaard commented 1 month ago

I have the exact same problem image

gcapnias commented 3 weeks ago

Ditto...

bilemke commented 3 weeks ago

Hmm. Ran into errors today mentioning the same "Object reference not set to an instance of an object."

Before I found this GitHub issue, I found a forum post on AskWoody.com from April 2023 that may be related as well.. https://www.askwoody.com/forums/topic/updating-causing-problems-again/

I commented there as well (but post is "Awaiting Moderation")... Based on the OP's post there and some feedback from a Guest user later in the thread, I discovered something with recent versions (not sure how far back it goes)..

Although there are settings in the following registry key (and/or subkeys) that can exist without configuring the use of a WSUS server, it appears that at least Get-WUSettings from PSWIndowsUpdate results in the above error if any configuration values are present in the key/subkeys if "UseWUServer" is not configured one way or the other (0 - NotUse WSUS, 1- Use WSUS)..

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate

I had one or more settings configured already via registry/ADMX/GPO at the above location, but had not configured the setting defining if a WSUS server should be used or not.

The moment i created:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU UseWUServer

and set it to either 0 or 1, no more "Object reference not set to an instance of an object." errror.

igorakkerman commented 3 weeks ago

Same issue in my update script for always the same KB id: KB2267602 I installed the update manually, the error went away. The next day, the error re-appeared.

@bilemke I don't have that registry key at all: HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate

My script output:

Line |
 172 |      Get-WindowsUpdate -Install -AcceptAll
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Something goes wrong: Security Intelligence-Update für Microsoft Defender Antivirus – KB2267602 (Version 1.413.720.0) – Aktueller Kanal (Allgemein); Object reference not set to an instance of an object.
Get-WindowsUpdate: C:\system-config\system-update-core.ps1:172
Line |
 172 |      Get-WindowsUpdate -Install -AcceptAll
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Something goes wrong: Security Intelligence-Update für Microsoft Defender Antivirus – KB2267602 (Version 1.413.720.0) – Aktueller Kanal (Allgemein); Object reference not set to an instance of an object.
thedoctorjtd commented 2 weeks ago

Same here.

VERBOSE: Found [3] Updates in post search criteria
Get-WindowsUpdate: D:\Windows Locations\Documents\Scripts\updateAndShutdown.ps1:39
Line |
  39 |          Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot -Verbose
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Something goes wrong: Windows Malicious Software Removal Tool x64 - v5.126 (KB890830); Object reference not set
     | to an instance of an object.
Get-WindowsUpdate: D:\Windows Locations\Documents\Scripts\updateAndShutdown.ps1:39
Line |
  39 |          Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot -Verbose
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Something goes wrong: Windows Malicious Software Removal Tool x64 - v5.126 (KB890830); Object reference not set
     | to an instance of an object.
Get-WindowsUpdate: D:\Windows Locations\Documents\Scripts\updateAndShutdown.ps1:39
Line |
  39 |          Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot -Verbose
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Something goes wrong: 2024-07 Cumulative Update for .NET Framework 3.5 and 4.8.1 for Windows 11, version 23H2
     | for x64 (KB5039895); Object reference not set to an instance of an object.
Get-WindowsUpdate: D:\Windows Locations\Documents\Scripts\updateAndShutdown.ps1:39
Line |
  39 |          Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot -Verbose
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Something goes wrong: 2024-07 Cumulative Update for .NET Framework 3.5 and 4.8.1 for Windows 11, version 23H2
     | for x64 (KB5039895); Object reference not set to an instance of an object.
Get-WindowsUpdate: D:\Windows Locations\Documents\Scripts\updateAndShutdown.ps1:39
Line |
  39 |          Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot -Verbose
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Something goes wrong: 2024-07 Cumulative Update for Windows 11 Version 23H2 for x64-based Systems (KB5040442);
     | Object reference not set to an instance of an object.
Get-WindowsUpdate: D:\Windows Locations\Documents\Scripts\updateAndShutdown.ps1:39
Line |
  39 |          Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot -Verbose
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Something goes wrong: 2024-07 Cumulative Update for Windows 11 Version 23H2 for x64-based Systems (KB5040442);
     | Object reference not set to an instance of an object.
RomboDeadfish commented 2 weeks ago

I had this issue on 1 Windows 11 PC last month. Didn't affect the Windows 10 PCs at all. This month most of the Windows 11 PCs across 3 sites are doing it. The only option that I have set in the registry for this is to disable the automatic updates. I tried adding the WSUS parameter and set it to zero. Still get the same error. I tried removing the entire key and the error persists. Something that MS did most likely broke it.

PS C:\Windows\system32> Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot Install-WindowsUpdate : Something goes wrong: 2024-05 .NET 7.0.20 Security Update for x64 Client (KB5039844); Object reference not set to an instance of an object. At line:1 char:1 + Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot + ~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-WindowsUpdate], Exception + FullyQualifiedErrorId : Debug,PSWindowsUpdate.GetWindowsUpdate Install-WindowsUpdate : Something goes wrong: 2024-05 .NET 7.0.20 Security Update for x64 Client (KB5039844); Object reference not set to an instance of an object. At line:1 char:1 + Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot + ~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-WindowsUpdate], Exception + FullyQualifiedErrorId : Debug,PSWindowsUpdate.GetWindowsUpdate Install-WindowsUpdate : Something goes wrong: Windows Malicious Software Removal Tool x64 - v5.126 (KB890830); Object reference not set to an instance of an object. At line:1 char:1 + Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot + ~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-WindowsUpdate], Exception + FullyQualifiedErrorId : Debug,PSWindowsUpdate.GetWindowsUpdate Install-WindowsUpdate : Something goes wrong: Windows Malicious Software Removal Tool x64 - v5.126 (KB890830); Object reference not set to an instance of an object. At line:1 char:1 + Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot + ~~~~~~~~~~~~~

braxtoon-hash commented 1 week ago

Same problem here, any news on how to fix it ? Your stuff didn't work for me @bilemke

githubRover commented 1 week ago

@braxtoon-hash Have you seen this yet? Rollback instructions from MS https://github.com/mgajda83/PSWindowsUpdate/issues/27#issuecomment-2237446245

braxtoon-hash commented 1 week ago

@braxtoon-hash Have you seen this yet? Rollback instructions from MS #27 (comment)

Thanks i'll look into that

callworthp commented 4 days ago

Updating PSWindowsUpdate to version 2.2.1.5 resolved the issue for me.