Can't install updates with Powershell Windows update script after KB5040442

Norbert Végh 20 Reputation points
2024-07-23T13:38:06.2466667+00:00

I am using the following script to update Windows images during Hashicorp Packer builds: https://www.powershellgallery.com/packages/AppVeyorBYOC/1.0.82/Content/hyper-v%5CWindows%5Cscripts%5Cwin-updates.ps1

The script stopped working on Windows 11 22h2 and 23h2 OS versions after installing the KB5040442 update.

I ran a simplified version of the script on my fully updated W11 23H2 laptop to list the details of the already installed updates:

*> $script:UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'

$script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
$script:SearchResult = New-Object -ComObject 'Microsoft.Update.UpdateColl'
$script:SearchResult = $script:UpdateSearcher.Search("IsInstalled=1 and Type='Software' and IsHidden=0")**
$script:SearchResult.Updates.Count 9**
Write-Host "Update Title is: $($script:SearchResult.Updates.Item(1).Title)"
Update Title is:*

 

It sees 9 installed software updates, but the title (or any other property) can’t be printed.

Is this a known issue with KB5040442? I saw that there are potential problems with it at https://www.windowslatest.com/2024/07/18/windows-11-kb5040442-issues-update-fails-to-install-causes-other-problems/, but this particular one wasn't among them.
What could I do against this issue?

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,392 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 33,296 Reputation points
    2024-07-24T01:17:20.4133333+00:00

1 additional answer

Sort by: Most helpful
  1. Zunhui Han 1,835 Reputation points Microsoft Vendor
    2024-07-23T15:49:17.05+00:00

    Hi Norbert Végh,

    Thank you for posting in Q&A forum.

    First, you could try uninstalling the update and see if that resolves the issue. To do this, go to Settings > Update & Security > Windows Update > View update history > Uninstall updates. Find the update in question and click Uninstall.

    If the issue is caused by update KB5040442, it is recommended to provide feedback to Microsoft. You can send feedback using the Feedback Hub app in Windows 10 and 11.Microsoft usually pays attention to user feedback. If a user reports this issue, Microsoft will fix it in a subsequent update.

    Please refer to this link.

    https://support.microsoft.com/en-us/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332

    I hope the information above is helpful.

    Best regards

    Zunhui

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.