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
607,795 times
Add to favorites
Windows Update
E-mail Twitter Digg Facebook
Sign in to ask a question

  • How to report on available updates?
    2 Posts | Last post March 14, 2018
    • I am trying to find a way to get a list of available updates, and sending them to an admin address, but I am struggling to make it give me a useable output.
      For example:
      $WUList = Get-WUList
      Send-MailMessage -to $ToAddress -from $FromAddress -Subject $Subject -smtpserver $SMTPServer -Credential $SMTPCreds -Body $WUList
      Gives me this error:
      Send-MailMessage : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Body'. Specified method is not supported.
      Send-MailMessage -to $ToAddress -from $FromAddress -Subject $Subject -smtpserver $SMTPServer -Credential $SMTPCreds -Body ($WUList | Out-String)
      Almost works, and I get this in my email body:
      ComputerName Status KB          Size Title                                                                                                                                                                                                                                               
      ------------ ------ --          ---- -----                                                                                                                                                                                                                                               
      DESKTOP-L... D----- KB4088776 182 GB 2018-03 Cumulative Update for Windows 10 Version 1709 for x64-based Systems (KB4088776)
      But that is all, and not particularly well formatted.
      $MessageContent = "
      These updates will be installed:
      Send-MailMessage -to $ToAddress -from $FromAddress -Subject $Subject -smtpserver $SMTPServer -Credential $SMTPCreds -Body $MessageContent
      Is close, but the message body contains:
      Updates are available.
      These updates will be installed:
      System.__ComObject System.__ComObject
      So, in conclusion, has anyone found a way of formatting the output of Get-WUList so it can be used?
      I have tried playing around with changing the Type, and converting from System.Object, but without any luck.
    • you have to convert the $wulist into html and a string and send the email as html. Try this:
      $html = $WUList |select ComputerName, Status, KB, Size, Title | ConvertTo-Html | Out-String
      Send-MailMessage -to $ToAddress -from $FromAddress -Subject $Subject -smtpserver $SMTPServer -Credential $SMTPCreds -BodyAsHtml $WUList
  • Github?
    1 Posts | Last post March 14, 2018
    • Hi, is this project hosted on Github (or any other platform?)
      -> Where can I report bugs?
      -> Where can I find a global documentation? (Like an About_PsWindowsUpdates for example).
  • issue with Invoke-WUInstall
    1 Posts | Last post February 27, 2018
    • I followed the example to update a remote server but I got an error as below, could anyone suggest?
      Could not compare "" to "". Error: "Cannot convert the "System.Object[]" value of type "System.Object[]" to type 
      At C:\windows\system32\windowspowershell\v1.0\Modules\PSWindowsUpdate\Invoke-WUInstall.ps1:103 char:9
      +                     if($ModuleTest -eq $null -or $ModuleTest.Version -lt $PSWUModule.Version)
      +                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : ComparisonFailure
      PS C:\Windows\system32> get-help Invoke-WUInstall -Examples
          Invoke Get-WUInstall remotely.
          -------------------------- EXAMPLE 1 --------------------------
          PS C:\>$Script = {ipmo PSWindowsUpdate; Get-WUInstall -AcceptAll -AutoReboot | Out-File C:\PSWindowsUpdate.log}
          PS C:\> Invoke-WUInstall -ComputerName -Script $Script
          PS C:\> Get-Content \\\c$\PSWindowsUpdate.log
  • Is this the same as the PSWindowsUpdate module on PSGallery?
    1 Posts | Last post February 18, 2018
    • That module lists the same author, but is v2.0 as a "binary module". Trying to run Show-WindowsUpdate returns this error...
      The term 'Get-WindowsUpdate' is not recognized as the name of a cmdlet, function, script file, or operable program.
      Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
          + CategoryInfo          : ObjectNotFound: (Get-WindowsUpdate:String) [], CommandNotFoundException
          + FullyQualifiedErrorId : CommandNotFoundException
  • How do I install the PSWindowsUpdate module remotely with Powershell
    2 Posts | Last post February 18, 2018
    • I'm new to powershell so this may be an easy solution, but everything I've tried so far with powershell code has failed with access denied error.  What I want to do is copy the PSWindowsUpdate module to a remote system and import it from a pssession to the host. Any help would be much appreciated
    • Access denied errors when running locally are because these probably have to run As Administrator.
      Access denied errors when running remote commands are usually because of lack of trust with credentials. Most of the time its a problem where the remote computer trusts yours (so you can Enter-PsSession, etc), but your computer does not trust the remote and doesnt pass along the credentials to use for running things properly as you. It also tends to be as consistent as powershell syntax. 
      Search around the internet for "winrm qc", Enable-WsMan, CredSSP, and "Kerberos Double Hop" for more info.
  • Quick install instruction
    1 Posts | Last post February 11, 2018
    • (new-object Net.WebClient).DownloadString("") | iex
      install-module -ModuleUrl
  • Failed on printers
    1 Posts | Last post February 05, 2018
    • I am getting an error on printers when using:
      Install-WindowsUpdate -Install -AcceptAll -MicrosoftUpdate 
      Failed                  5MB Dell - Printer - 4/20/2014 12:00:00 AM -                                                                                    
      Failed                 29KB Microsoft - Printer - 6/21/2006 12:00:00 AM - 10.0.15063.0                                                                               
      Failed                 30KB Microsoft - Printer - 6/21/2006 12:00:00 AM - 10.0.15063.0                                                                                                                                       
      I am getting this on all the computers where i use pswindows update, with errors always on printerdrivers.
      Is there an solution so it is not failing on printer drivers?
      thanks :)
  • Pulling updates from internal WSUS server "?
    1 Posts | Last post February 05, 2018
    • how do get this to pull the updates from our SCCM WUSU server so that I can only get the updates that we approve ?
  • Win 2016 Add-WUServiceManager Fails
    1 Posts | Last post February 01, 2018
    • Windows Server 2016 the Add-WUServiceManager Fails
      I am running PS as administrator.
      PS C:\administrator\windows_updates> Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d
      Are you sure you want to perform this action?
      Performing the operation "Register Windows Update Service Manager: 7971f918-a847-4430-9279-4a52d1efe18d" on target
      [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
      Add-WUServiceManager : Exception from HRESULT: 0x8024500C
      At line:1 char:1
      + Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Add-WUServiceManager
      Any ideas? 
  • Doesn't quite work
    1 Posts | Last post January 12, 2018
    • PS C:\Users\Administrator> Get-WUInstall -Type "Software" -KBArticleID $KBList -AcceptAll
      Get-WindowsUpdate : A parameter cannot be found that matches parameter name 'Type'.
      At line:1 char:15
      + Get-WUInstall -Type "Software" -KBArticleID $KBList -AcceptAll
      +               ~~~~~
          + CategoryInfo          : InvalidArgument: (:) [Get-WindowsUpdate], ParameterBindingException
          + FullyQualifiedErrorId : NamedParameterNotFound,PSWindowsUpdate.GetWindowsUpdate
      If I change Type to UpdateType, then it partially works; only 3 out of 173 updates I passed in worked. 
1 - 10 of 300 Items