Skip to content

Instantly share code, notes, and snippets.

@tom-henderson
Created August 23, 2017 01:17
Show Gist options
  • Save tom-henderson/a2435e7860506e810e87e1e6131bfc75 to your computer and use it in GitHub Desktop.
Save tom-henderson/a2435e7860506e810e87e1e6131bfc75 to your computer and use it in GitHub Desktop.
Get pending windows updates.
function Get-AvailableUpdates {
[CmdletBinding()]
Param()
$wu_session = New-Object -ComObject Microsoft.Update.Session
$wu_searcher = $wu_session.CreateUpdateSearcher()
$updates = $wu_searcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
return $updates.Updates `
| Select Title, RebootRequired, IsInstalled, IsDownloaded, IsHidden, IsPresent, `
@{Name='KbArticleIds';Expression={$_.KbArticleIds}}, `
@{Name='CveIds';Expression={$_.CveIds}}, `
@{Name='Size (MB)';Expression={[math]::truncate($_.MaxDownloadSize / 1MB)}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment