Check for Windows Updates Using PowerShell

As an IT administrator, you might need to check for Windows updates in your organization. A PowerShell script is suitable for checking for updates in multiple systems.

Let me show you here how to check for Windows updates using PowerShell.

If you manage multiple computers, especially in a corporate environment, you can use this PowerShell script to check for Windows updates in multiple systems.

Here, you will see multiple methods to check for Windows updates using PowerShell, including built-in cmdlets and third-party modules.

Prerequisites

Before you start with the PowerShell script, make sure you have the following:

  • A Windows operating system (Windows 10 or later)
  • PowerShell version 5.1 or later
  • Administrative privileges to run PowerShell scripts

Check for Windows Updates Using PowerShell

There are various methods to check for Windows updates using PowerShell.

Method 1: Using Get-WindowsUpdate from the PSWindowsUpdate Module

To manage Windows updates using PowerShell, you need to install the PSWindowsUpdate module. This module provides cmdlets for managing Windows updates.

Open the Windows PowerShell, run it as administrator, and then run the cmdlets below.

Install-Module -Name PSWindowsUpdate -Force

If prompted to trust the repository, type Y and hit Enter.

Then, you need to import the module using the below cmdlet.

Import-Module PSWindowsUpdate

Once the PSWindowsUpdate module is installed, you can use it to check for updates.

To check for available updates in Windows OS, use the Get-WindowsUpdate cmdlet:

Get-WindowsUpdate

This command scans your system and lists all pending updates. The output will include details such as the update title, KB number, and whether a reboot is required.

You can see the exact output in the screenshot below:

Check for Windows Updates Using PowerShell

You can filter the updates based on various criteria. For example, to list only the security updates in the Windows OS, use the following command:

Get-WindowsUpdate | Where-Object {$_.Title -like "*Security*"}

You can also export the report of all available updates to a .txt file like below:

Get-WindowsUpdate | Out-File -FilePath "C:\UpdateList.txt"

Or you can also export in CSV format using the following command:

Get-WindowsUpdate | Select-Object Title, KB, Size | Export-Csv "C:\UpdateReport.csv" -NoTypeInformation

Check out Install Windows Updates Using PowerShell

Method 2: Using Windows Update COM Object (Legacy Method)

This method is suitable for older systems that may not support newer modules.

To use this:

  • First, you need to create a COM object
$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
  • Then, Search for Updates
$SearchResult = $UpdateSearcher.Search("IsInstalled=0")
  • Then you can use the below script to display the update details:
$SearchResult.Updates | ForEach-Object {
    Write-Host "Title: $($_.Title)"
    Write-Host "Description: $($_.Description)"
    Write-Host "---------------------------------------------"
}

Read Install .NET Framework 3.5 Using PowerShell

Method 3: Using Get-WUList (Alternative to Get-WindowsUpdate)

Now, let me show you the third method to get Windows updates in PowerShell.

If you’re using the PSWindowsUpdate module, another helpful command is Get-WUList.

Get-WUList

This command lists all available updates without triggering the installation process.

Check out Install RSAT in Windows 11 Using PowerShell

Troubleshooting Common Issues

You may encounter some common issues while using PowerShell to manage Windows updates. Here are a few troubleshooting tips:

Issue: Module Not Found

If you receive an error stating that the PSWindowsUpdate module is not found, ensure that you have installed the module correctly. Run the following command to verify the installation:

Get-Module -ListAvailable PSWindowsUpdate

If the module is not listed, reinstall it using the Install-Module command.

Issue: Access Denied

If you encounter an “Access Denied” error, make sure you are running PowerShell with administrative privileges. Right-click on PowerShell and select Run as administrator.

Conclusion

In this tutorial, I explained how to check for Windows updates using PowerShell using the Get-WindowsUpdate cmdlet. Please let me know if this works fine.

You may also like:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.