If you have a WSUS server and deploy new or re-image computers on a regular basis you know that waiting for Windows to find the latest updates can be slow. This PowerShell script will help speed up the process by using with the Microsoft.Update.Session COM object to force the download an install of the latest approved updates.

This powershell script is adapted from the VBScript (WUA_SearchDownloadInstall.vbs) Microsoft released. However, unlike the Microsoft equivalent it eliminates the need for user input intervention by providing the ability to pass command line arguments.

Yeah, just so everyone knows the “truth” but this script will not work in its entirety, so the updates will be found, will download, will install but it will not reboot. You will see some gibberish but basically it is will say “Privilege Not Held” because you cannot initiate a reboot of the machine where you run the script, so others have run the script on other machines calling the machine in question but if you use something like AdminArsenal then you know the script is copied over and run.
I won’t try to solve the problem above and will leave that to Gregory to troubleshoot his code because it is flying all over the internet but does not work 100% meanwhile I just upgraded my VMs to PowerShell 2.0 and then I can just swap out his line for REBOOT with:
Restart-Computer

Problem solved for me, but I guess others might still be running PowerShell 1.0 so upgrade dammit…

http://www.gregorystrike.com/ Gregory Strike

Wilfredo, Thanks for bringing this issue to my attention. I’ve posted an update to the script above and I believe it will fix the issue. I’ve replace the single Reboot line with:

However, I’m not 100% certain that will work on PowerShell 1.0. I believe it will. I would like to hear if it does not. There’s another method I could do that would launch the shutdown.exe task as a remote process, so it wouldn’t be within PowerShell, and should work, I just thought the above fix was cleaner.

Can I execute this from my desktop and have it work against a remote machine?

LUCKY ADMIN

EXCELLENT SCRIPT!!! SAVED HOURS SIR!!!

Jocke

i am having some issues with this script, i want to run it remotly on a number of computers, however when i tried it against my colleagues computer i got this:
C:skripts> Invoke-Command -ComputerName mawe-764 -FilePath .wsus.ps1 -ArgumentList y,ySearching for applicable updates…
List of applicable items on the machine:1> Security Update for Windows 7 for x64-based Systems (KB2698365)2> ….
Downloading Updates…Exception calling “CreateUpdateDownloader” with “0” argument(s): “Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))”

useing a domain admin account that are local administrator on his computer, he also enabled psremoting and started the winrm service

any ideas?

jocke

also, it will list my applicable updates but while starting to download them, the script stops…

does this have anything to do with wsus policy settings?

/J

Andre

First of all, great script, thank you for sharing it with us!!
Is there an easy way to write the installed patches or the Status of what the script did into a text file? Could be helpful if it is running as scheduled Task to check what was installed or if there was any error during the run…

Ghe

Great !
I customize his execution for managing update on hyper-v cluster nodes, works very well !

Troy Frank

anyone else have jocke’s problem? I did, and haven’t been able to find a solution so far.

Colin Westwater

I am having the exact same issue as Jocke. Can anyone help? Many thanks to Gregory for such a useful script!