Answer the question
In order to leave comments, you need to log in
Problem installing updates, what's wrong?
Good day everyone!
There is this code:
$searcher = New-Object -ComObject Microsoft.Update.Searcher
$session = New-Object -ComObject Microsoft.Update.Session
$installer = New-Object -ComObject Microsoft.Update.Installer
$searcher.Online = $true
$searcher.ServerSelection=1
$results = $searcher.Search("IsInstalled=0")
$updates = $results.Updates
$updateCollection = New-Object -ComObject Microsoft.Update.UpdateColl
ForEach($update in $updates) { $updateCollection.Add($update) }
$downloader = $session.CreateUpdateDownloader()
$downloader.Updates = $updateCollection
$downloader.Download()
$installer.Updates = $updateCollection
$installer.Install()
Index was outside the bounds of the array.
At line:24 char:1
+ $installer.Updates = $updateCollection
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], IndexOutOfRangeException
+ FullyQualifiedErrorId : System.IndexOutOfRangeException
Exception from HRESULT: 0x80240004
At line:25 char:1
+ $installer.Install()
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question