Share via

WSUS Updates Powershell script fails; Errorcode: 0x80240438

Anonymous
2018-11-30T10:56:43+00:00

Hello,

I am trying to run a powershell script on a Windows Server 2016 to find, download and install updates, but I get the following error:

Exception from HRESULT: 0x80240438

...

  • $result = $updateSearcher.Search("IsInstalled=0 and Type='Software'")
  • 
    

    + CategoryInfo          : OperationStopped: (:) [], COMException

    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

Here is my script:

Write-Host "Installing WSUS-Updates"

$updateSession = New-Object -Comobject Microsoft.Update.Session

$updateSearcher = $updateSession.CreateUpdateSearcher()

$result = $updateSearcher.Search("IsInstalled=0 and Type='Software'")

if ($result.Updates.Count -eq 0){

    Write-Host "No available updates" 

    exit

}

$updatesToDownload = New-Object -Comobject Microsoft.Update.UpdateColl

foreach ($update in $result.Updates){

    $updatesToDownload.Add($update)

}

$downloader = $updateSession.CreateUpdateDownloader()

$downloader.Updates = $updatesToDownload

$downloadResult = $downloader.Download()

$updatesToInstall = New-Object -Comobject Microsoft.Update.UpdateColl 

foreach ($update in $result.Updates){

    if ($update.IsDownloaded) {$updatesToInstall.Add($update)}

}

$installer = $updateSession.CreateUpdateInstaller()

$installer.Updates = $updatesToInstall

$installationResult = $installer.Install()

exit

I tried running it with admin privileges also, but did not help.

WUServer and WUStatusServer register keys are set to the same path (I read that this may be the problem..)

What could possibly cause the issue?

Thank you in advance!!

Windows for home | Windows 10 | Windows update

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Sumit D - IA 170.9K Reputation points Independent Advisor
    2018-11-30T11:59:47+00:00

    Hi,

    Please ask on our sister site Technet which can handle WSUS questions better.

    https://social.technet.microsoft.com/Forums/en-...

    Was this answer helpful?

    0 comments No comments