PSWindowsUpdate is a sophisticated PowerShell module that helps you install Windows updates with your PowerShell scripts.

Michael Pietroforte

Michael Pietroforte is the founder and editor in chief of 4sysops. He has more than 35 years of experience in IT management and system administration.

After Miroslav recommended PSWindowsUpdate in a comment, I tried Michal Gajda’s PowerShell module. I was surprised at how versatile its functions are. The only requirement is that you have at least PowerShell 2.0 installed.

If you want to try the cmdlets at the PowerShell prompt, you have to import the module first. To do so, extract the zip file to your PowerShell module folder ($HOME\Documents\WindowsPowerShell\Modules ) and then import the module with the Import-Module cmdlet.

Of course, you can also just use the module’s functions in your scripts without importing them. Once the module is imported, you have the following cmdlets at your disposal.

Get-WUList: Get a list of available updates that meet certain criteria ^

If you just want to get an overview of the available updates or to search for updates, this cmdlet will be helpful.

Get-WUInstall: Download and install updates ^

This cmdlet is the core of the PowerShell module. It comes with quite a few parameters. You can choose whether the updates are downloaded from your WSUS server or from Microsoft Update. You can specify updates or categories, configure the reboot behavior, and do much more.

Get-WUInstall example

Get-WUInstall example

Add-WUOfflineSync: Register offline scanner service ^

This function allows you to install updates from a local cache. You can work with either the old wsusscan.cab or the new wsusscn2.cab. If you want to automate the download of the CAB file, you should look at this PowerShell script.

Remove-WUOfflineSync: Unregister offline scanner service ^

If you registered the offline scanner service with Add-WUOfflineSync, you can use this function to unregister the service.

Get-WUServiceManager: Display Service Manager configuration ^

Sometimes you have to check which update service is configured on the computer (Windows Update, Microsoft Update, WSUS, or offline sync service).

Get-WUHistory: Get a list of previous updates ^

You can list the installed updates on either a local machine or a remote one.

Get-WUInstallerStatus: Check Windows Update Installer status ^

This cmdlet verifies that the Windows Installer is ready. You might want to check this at the beginning of your scripts.

Get-WURebootStatus: Check Windows Update reboot status ^

You can use this command in scripts to determine if a specific update requires a reboot.

Get-WUUninstall: Uninstall update ^

This cmdlet takes an update ID as input and uninstalls the corresponding update.

At the beginning of each function, you’ll find a detailed description, a list of parameters, and examples.

The advantage of PSWindowsUpdate over the two update command-line tools I discussed previously (WuInstall and ABC-Update) is that you can easily integrate PSWindowsUpdate’s functions in your PowerShell scripts. If you work with another scripting solution, you might prefer one of the other two tools.

Join the 4sysops PowerShell group!

0
Share
5 Comments
  1. Casey 4 years ago

    Just throwing this out there as I become more frustrated by the day with the number of sites that simply state information that is available already. Most often what is missing is good examples of how to use the tool / software as is the case here. How about a scenario of I am sitting on Computer A and I would like to query that patches are already installed on Computer B. What would be the step by step instructions. Not everyone can infer the rights steps to take. Especially when they are starting out and this need is the starting point.

    Then progress to what to do to see what patches are needed on Computer B. A nice article along these lines would really clear things up for folks. Just saying.

    7+

  2. part 3 years ago

    Hi, Can i use this to update the patches from my local WSUS server? Do i need to mention the local WSUS in the script or need to create it using GPO.

    0

    • Author
      Michael Pietroforte 3 years ago

      By the default, Get-WUInstall uses the WSUS server configured in in the computer policy.  If you don't want to use WSUS, you have to add the -MicrosoftUpdate parameter.

      0

  3. Alan Jebakumar 3 years ago

    Can we use this module integrated with DSC to install updates on windows machines?

    0

  4. Peter 2 years ago

    I would like to be able to run these from an invoke-command and get some feedback (I'm mostly interested in the status ones) but it seems that it is blocked. Any ideas?

    0

Leave a reply to Casey Click here to cancel the reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2019

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account