Windows Update PowerShell Module

This function is a piece of PSWindowsUpdate module to manage Windows Update on a computer system running Windows. Whole module contain set of functions to check, download and install updates from PowerShell.

4.6 Star
734,100 times
Add to favorites
Windows Update
E-mail Twitter Digg Facebook
  • Remoting
    4 Posts | Last post December 11, 2011
    • Have you tested using remote management?
      Will they still work if called from and invoke-command cmdlet?
    • Hi,
      Thanks for post. I test it with Invoke-Command and indeed it's broken. 
      But i know what is wrong then i couple days I try fix this.
    • Sorry it will be works only locally - at least for now. I tried fix this whole week and now I found that on MSDN site: 
      CreateUpdateDownloader()- This method cannot be called from a remote computer
      CreateUpdateInstaller()- This method cannot be called from a remote computer
    • i also run over this problem.
      i tried wuauclt /updatenow which definetly doesn´t work when i use a ps-session to the remote-host.
      have you heard anything new since then?
  • Proper use of ? examples/implications?
    2 Posts | Last post November 24, 2011
    • Thanks for PSWindowsUpdate_1.3.1 !!! wow!  Hey, I may need more info, my goal - briefly connect to internet (just long enough to download (only) updates, disconnect from internet - then at a later time install these updates on the download machine - or another machine - isn't that what helps me do?  On another machine (no internet connection) it has the latest that is a refrence against which I can then install the previously downloaded (only downloaded) updates?  So I guess I need to understand how is utilized (on a Win7 Enterprise box) where I don't actually have a WSUS Server.  Also need to understand how to 2-step this thing so first - just download only...then 2nd install the updates that were downloaded (even though I no longer have a connection to the internet) - and possibly from another machine - can't I copy off the directoryies (that were downloaded) apearantly to: C:\Windows\SoftwareDistribution\Download over to another similair PC then run an install (that doesn't have to check back with microsoft web site)?
      Thanks in advance!
    • Hi Dave, if I remember correctly lets you perform a offline scan for missing updates on machine. Maybe it is possible to install offline updates that was downloaded earlier, however I never tested this. To scan offline you need register Add-WUOfflineSync -Path C:\, copy ServiceID and use it in: Get-WUInstall -ServiceID <ServiceID>
  • Unattended Update Installation
    12 Posts | Last post November 10, 2011
    • I was just wondering whether this module could be used to install Windows Updates without user interaction.
      We have a bunch of PCs (Win7, WinXP) using a Disk Protection Software so that any changes made to the system a reverted at system boot. There are mechanisms to automatically turn off that protection (once a week/month), prohibit any kind of user interaction, run scripts to update software or whatever and turn protection back on as soon as all scripts have terminated (or timed out :-().
      What I'm looking for is a way to call a Get-WUInstall automatically in a "fire and forget" manner the only requirement being that it terminates only when it's done (i.e. no backgrounding).
    • You tried to use the cmdlet Get-WUInstall together with the parameters -All to accept all updates? Also in new version I add next params -AutoReboot.
    • I did find the -All option, but I don't get the cmdlet to work for me. I can manually run PowerShell, import the Module and run Get-WUInstall - works perfectly. I didn't know about -AutoReboot. That sound's great for me.
    • I add AutoReboot yesterdey specifically to meet your requirements ;)
    • That's great! Thanks a lot! As far as I'm concerned, there's just one issue left: I created a install_updates.cmd containing one line: Powershell.exe -noprofile -executionpolicy Bypass C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSWindowsUpdate\Get-WUInstall.ps1 and it simply does nothing. I tried an explicit "Run as Administrator" and a couple of other options - no success. I wouldn't be surprised if that problem is trivial to you... :)
    • Hi again. If you load it just: "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSWindowsUpdate\Get-WUInstall.ps1", it do nothing. It load this source in other scope then your console works. Try load it with dot sourcing operator: ". C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSWindowsUpdate\Get-WUInstall.ps1". But remember it only declar new function:  Get-WUInstall. Next you need write second line to execute this function with appropriate parameters.
    • Ohh. Sorry I forgot you do this from cmd :). Try add to this file Get-WUInstall.ps1 at end Get-WUInstall with appropriate parameters. Then If you execute this file you declar new function and execute it at end.
    • To be honest, considering the fact that I'm trying to do something rather simple I expected this to be a tiny bit less complicated. ;-) Now, I think I understood your first posting and I am able to run PowerShell and execute the script just fine. As far as I can tell the script works as expected. However, I'm still not able to get this thing to run from cmd. Most likely the reason is that I'm just loading the script, not executing it. I've read various documentations but so far I haven't found any solution that works vor me... :-(
    • Wait! I think I got it! I had a bit of trouble understanding what you were trying to tell me - maybe because I didn't expect it to be that simple: I modified not my "install_updates.cmd" but the original "Get-WUInstall.ps1" adding just one line ("Get-WUInstall"). First you declare the function - then you call it. Just as you wrote. Thanks a lot for your help. I think I can go on from here on my own. 
    • No problem, it was nice to help to solve this problem :).
    • Thanks for adding AutoReboot!
    • Hi again. No problem, I love scripting so if somebody want to add or modify something, let them write here :)
  • HOw automatize ?
    2 Posts | Last post October 20, 2011
    • Hello,
      If someone could explain me how automatize this module to be importedonce for all ?
      When I restard my server I have to replay the Import-Module PSWindowsUpdate and put R all the time ?
    • Hi Nikauch. First, when you restart server, yes you need import module again - or if you want change it, try put it in your profile file (PS> "notepad $profile"). Then Powershell load modul automaticly at start. Put R, I think you have ExecutionPolicy set on RemoteSigned - (1, I think the best way) try to sign this script. (2) or try to unlock the script files that these files aren't downloaded from the internet (on file->Property->Unlock). (3 worst way) set ExecutionPolicy to unrestricted.
  • Checking RebootRequired
    2 Posts | Last post July 06, 2011
    • First of all thank you for sharing this script with us.
      But it seems to me like the part where you check whether a reboot is required or not is slightly dysfunctional (in the Get-WUInstall function).
      Because you may end up in a scenario where the first patch requires one, thus setting the variable $needsReboot to $true. But the subsequent patch doesn't require one, thus setting it to $false.
      Also would it be possible to query the "Microsoft.Update.SystemInf" instead of checking the installation results?
    • Hmm... I think you're right. It should be:
      if(!$needsReboot){ $needsReboot = $installResult.RebootRequired }
      If false then change status and stay that. Also may use Microsoft.Update.SystemInfo at finish.
      Thanks for help.
  • Nice script, very useful for me
    2 Posts | Last post April 01, 2011
    • I did the following.
      Created a file called install_updates.cmd
      In that command file I put one single line to call your script.
      Powershell.exe -noprofile -executionpolicy Bypass \\server\Path\Get-WUInstall.ps1
      I also updated your script to include the call to the function by putting the following in the script
      Get-WUInstall -all
      Works like a treat. . . thanks again.
    • Then i just copy the UNC path into a cmd prompt on the server and press enter:
      \\server\Path\install_updates​.cmd   <Enter>
  • How to use script
    3 Posts | Last post February 22, 2011
    • Could you please share few examples on How to use this script ?
    • example:
      Save the script to C:\Update.ps1
      Open Power Shell and type:
      import-module C:\Update.ps1
      Will download and install updates with your approval
      Get-WUInstall -downloadonly
      Will only download updates
      Get-WUInstall -all
      Will accept all questions
      Thanks for the great script!
    • Thx Zebbelin.
      Some examples are available in help, but not all: 
      Get-Help Get-WUInstall –Examples. 
      If you need more function I recommend download full module from
      I always try there to have the current version include fixed all reported bugs. 
351 - 357 of 357 Items