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:
- Install Windows using WSIM/autounattend.xml
- Run a PS script that executes automatically upon first logon
- 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?