Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell WUA script hangs on calling Update() and Install()

$
0
0

I am trying to write a script that will use the WUA API to install certain updates. I have written many Powershell scripts, but this is my first time using COM objects, or interacting with the WUA API. I have used the code from this article: http://msdn.microsoft.com/en-us/library/windows/desktop/aa387102(v=vs.85).aspx I added in my own code to filter the available updates to a list of updates that I want to install. Everything is working fine, except the script hangs after the calls to both Download() and Install().

When I call Download(), the updates are successfully downloaded, but the script will not continue on. The cursor just sits there blinking. If I monitor WindowsUpdate.log, waiting until the updates are finished downloading, return to the Powershell window, and press the <Enter> key, the script continues on. The same happens with my call to Install().

Here are the sections of code at issue:

'Downloading updates...'
$downloader = $UpdateSession.CreateUpdateDownloader()
$downloader.Updates = $updatesToDownload
$downloader.Download()
"Done"

----------snip------------

"Installing Updates..."
$Installer = $UpdateSession.CreateUpdateInstaller()
$Installer.Updates = $updatesToInstall
$results = $Installer.Install()
"Done"

In neither case is the word "Done" displayed until after I hit <Enter>. The rest of the code is just as it is on the MSDN page linked above (the Powershell version). Why is this happening?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>