Skip to main content desktop
Try Now

Windows Update Using PowerShell

Jordan HammondJordan Hammond

Does Christmas come twice a year? If you installed the latest PDQ Inventory to get access to the PowerShell Scanner, then the answer is an absolute “yes it does.” Now that you have your hands on it, there are so many possibilities; it can be overwhelming. Why not let the sweet scripting of Nate and Colby get you started? They have quite a bit on our GitHub, and if there is something you feel like people can use, please make a pull request, and we can get it added. Out of all of the scripts there, let’s focus on ones involving Windows Updates.

Importing Required Modules

The pswindowsupdate module in PowerShell is not installed by default, so we would need to do this first to make sure the commands we use will be available. In a perfect world, you could just run a quick Install-Module and be done with it, and while the idea for that is good, there are some things to watch out for. It may not know where to look, or it may run into several issues. The first is that when importing the module, it will print out some lines saying it was done, which would return in a result and muddy up your results. So you will want to cast that to $null.

$null = Import-Module $ModuleName -Force

The second issue is that if it is already loaded, or it does not know where to look, you could get some errors. To avoid that, we use Try/Catch to test and handle those. So instead of the quick one-liner, to ensure we are not getting an error, we would want to put it all together in the script we have below.

param (
    [Parameter(Mandatory = $true)]

# Install the module if it is not already installed, then load it.
Try {

    $null = Get-InstalledModule $ModuleName

} Catch {

    if ( -not ( Get-PackageProvider -ListAvailable | Where-Object Name -eq "Nuget" ) ) {

        $null = Install-PackageProvider "Nuget" -Force


    $null = Install-Module $ModuleName -Force


$null = Import-Module $ModuleName -Force

Getting your Update Data

To make sure you don’t have to copy this full code, I recommend you follow these instructions for downloading and importing from the GitHub repository. You are creating a script to let you know what updates are missing when you last updated or getting an update history are all one quick command. 

I did include the full import script here, but I would strongly recommend if you plan to use these that you get them from the GitHub, so if updates are made, you can keep your scanners up to date with a quick command.


Hopefully, this helps get the creative juices going, and you can dive into your next bit of PowerShell brilliance. This is a fantastic tool that can make you seem like an IT superstar to your peers. Dive in and have fun!

This blog post is part of our PowerShell Scanner series.

Ready to put the PowerShell Scanner through its paces?

Take our 14-day Free Trial. Feel the power of the PowerShell scanner.
Start a Trial

Don't miss the next post!

Windows 11 First Look

Microsoft is gearing up for the release of Windows 11. Are you ready for it? Here's everything you need to know about Microsoft's newest operating system.

© 2021 Corporation
  • PDQ Deploy ®
  • PDQ Inventory ®
  • Pricing
  • Downloads
  • Licensing
  • Buy