-
-
Save 001101/c3cbb35ba4ac602ce2de4e1f9a40286f to your computer and use it in GitHub Desktop.
Check Windows updates using Windows Update Agent (WUA)
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 | |
The script uses a COM object to interact with the Windows Update service, searching for any updates that are currently available but not installed. If no updates are pending, it confirms the system is up to date. Otherwise, it lists all pending updates by title. | |
#> | |
# Create a COM object for Windows Update Session | |
$UpdateSession = New-Object -ComObject "Microsoft.Update.Session" | |
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher() | |
# Search for pending updates | |
$SearchResult = $UpdateSearcher.Search("IsInstalled=0") | |
# Check if there are updates available | |
if ($SearchResult.Updates.Count -eq 0) { | |
Write-Host "Your system is up to date." | |
} else { | |
Write-Host "There are updates pending. Details are as follows:" | |
foreach ($Update in $SearchResult.Updates) { | |
Write-Host "Update Title: $($Update.Title)" | |
} | |
} | |
# Inform the user about potential update restrictions | |
Write-Host "Note: Some updates, especially driver updates, may not be available due to management policies from RMM, Group Policy, Intune etc." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment