I’ve been using the PSWindowsUpdate module for a while now; it’s very convenient when spinning up a test VM for a customer if you want to have it up-to-date before going through the Windows Autopilot process, for example. In this blog post, I will show you how the module works with a few examples of how I use it.

How to install

Install-Module PSWindowsUpdate
Import-Module PSWindowsUpdate

Available cmdlets

Как обновить power shell

Examples

In the examples below, I use the PSWindowsUpdate module on a new Windows 11 Pro version 23h2 Hyper-V VM on my laptop that I deployed using the last ISO file from my VisualStudio subscription, released in December 2023. (I use it to install all updates before the Autopilot process so that the machine is up-to-date when deploying it)

Checking if updates are available

Running the Get-WindowsUpdate cmdlet will show you which updates are available to your system. You can use the -ComputerName parameter to connect to another system.

Как обновить power shell

Installing all updates

Running the Install-WindowsUpdate cmdlet will install all the updates found and show you the progress during installation. You can use the -AcceptAll parameter to avoid answering confirmations.

Как обновить power shell
Как обновить power shell
Как обновить power shell

It will prompt you to reboot the system if needed:

Как обновить power shell
Как обновить power shell

Retrieving the Windows Update history of a system

Running the Get-WUHistory cmdlet will show you the installed updates on the system, and you can use the -Last parameter to limit the number of updates returned in the list. For example, this will show you all the installed updates:

Как обновить power shell

Or only show the last two by using -Last 2 to show the previous two updates:

Как обновить power shell

Default only these properties are returned; using Format-List will show you more details:

Как обновить power shell

Install or uninstall a specific Windows update

If you need to uninstall an update, use the Uninstall-WindowsUpdate cmdlet with the -KBArticleID parameter. In the example below, I (try, because it failed and you can’t always uninstall updates, especially when you’re not in Windows at that moment like me when running this in before logging in to start the Autopilot process) uninstall the KB4023057 update from the system:

Как обновить power shell

And if you need to install an update, use the (You guessed it 😉 ) Install-WindowsUpdate cmdlet with the -KBArticleID parameter. In the example below, I installed the KB4052623 on the system, which was ready to be installed, which you can see because I ran the Get-WindowsUpdate command:

Как обновить power shell

More information

Wrapping up

I showed you the PSWindowsUpdate module, some of its capabilities, and how to use the excellent command line method to install and manage updates using PowerShell!