Last active
June 5, 2025 07:48
-
-
Save absahl/4cd656e5d3ba081c42e229f391b28c50 to your computer and use it in GitHub Desktop.
List available system updates on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Description: Queries the Windows Update Agent (WUA) API to list all updates that are available for installation. | |
| # Create an Update Session COM object (entry point to Windows Update API) | |
| $Session = New-Object -ComObject Microsoft.Update.Session | |
| # Create an UpdateSearcher to query for available updates | |
| $Searcher = $Session.CreateUpdateSearcher() | |
| # Search for updates where IsInstalled = 0 (i.e., not yet installed) | |
| $SearchResult = $Searcher.Search("IsInstalled=0") | |
| # Process and display each update in a formatted table | |
| $SearchResult.Updates | | |
| Select-Object ( | |
| 'Title', # Name of the update | |
| @{ Name = "KBArticleIDs"; Expression = { $_.KBArticleIDs -join "," } }, # Concatenate all KB IDs | |
| 'IsMandatory', # Indicates if the update is mandatory | |
| 'BrowseOnly', # True if the update is only visible in the optional section of UI | |
| @{ Name = "Categories"; Expression = { $_.Categories | ForEach-Object { $_.Name } -join "," } }, # All associated categories | |
| 'Type' # Type of update (e.g., Software, Driver, etc.) | |
| ) | Format-Table -AutoSize # Neatly format the output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment