PSWindowsUpdate fails to effect Windows updates

I am currently tasked with designing and implementing a basic automatic setup procedure for our support devices that are regularly loaned out. I am also a complete PS noob. It’s a simple three-stage affair:

  1. Install Windows using WSIM/autounattend.xml
  2. Run a PS script that executes automatically upon first logon
  3. Some more adjustments to be done by hand

As part of stage two, I am mostly installing some software, copying over a wallpaper and so on. Crucially, I am also trying to update Windows. As I understand, there used to be a built-in module WindowsUpdateProvider, which, though basic, would have sufficed for our requirements. Since it no longer exists, I am using PSWindowsUpdate instead.

Here’s the pertinent PS code:

Install-Module -Name PSWindowsUpdate -Force
Import-Module PSWindowsUpdate
Get-WindowsUpdate
Install-WindowsUpdate -AcceptAll -AutoReboot

Now here’s the twist: The update procedure fails regularly at the installing stage (i.e. downloading the KBs itself goes fine):

Install-WindowsUpdate : Ausnahme von HRESULT: 0x80248007
In D:\NepResources\nep_unattend.ps1:99 Zeichen:1
+ Install-WindowsUpdate -AcceptAll -AutoReboot 1>>"C:\Users\Neptun\Docu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-WindowsUpdate], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,PSWindowsUpdate.GetWindowsUpdate

As I understand, the error can be related to different things going wrong, including software agreements. However, if I check the updates manually using the “traditional” way via settings, it all works without a hitch.

I have tried a variety of workarounds:

  • Assuming autoupdates were interfering, disabling them in the registry > no dice
  • Assuming autoupdates were interfering, disabling the wuauserv service > this disables updates altogether

Since the updates work fine manually, I am suspecting there’s something wrong with my code, or that I am not using the package correctly. However, I have so far been unable to find anyone with the same problem. Any hints here?

crust_cheese,
Welcome to the forum. :wave:t4:

Since your issue is a very specific error involving a non standard PowerShell module it could be nearly impossible to find someone with the same issue and having a helpful tip for you. :man_shrugging:t4:

The error number indicates that the issue might not be the PowerShell code rather than the underlying Windows functions.

But since the updates seem to be installed correctly you have at least two options to deal with this situation. Either you ignore the error or you handle it gracefully with a try catch block.

For further investigations you may search for the error number shown in your error message (BTW: It doesn’t bother me but since this is an english forum you may translate German error messages in the future :wink: )

1 Like

You don’t say how you execute the update script. If it’s running remotely this is expected as MS has blocked the ability to remotely invoke updates this way. You’ll need to execute it as a scheduled task or with something like PSExec. It’s similar to the double hop issue. If it’s already running locally, then you may want to engage the project maintainers and submit an issue.

2 Likes