/
Get-WindowsUpdates.ps1
37 lines (33 loc) · 1.25 KB
/
Get-WindowsUpdates.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
param(
[string] $Filter = "IsInstalled = 1 and Type = 'Software'"
)
$objSession = New-Object -ComObject "Microsoft.Update.Session"
foreach($update in $objSession.CreateUpdateSearcher().Search($Filter).Updates)
{
foreach($bundledUpdate in $update.BundledUpdates)
{
foreach($content in $bundledUpdate.DownloadContents)
{
if ($content.IsDeltaCompressedContent)
{
write-verbose "Ignore Delta Compressed Content: $($Update.Title)"
continue
}
if ( $content.DownloadURL.toLower().EndsWith(".exe") )
{
write-verbose "Ignore Exe Content: $($Update.Title)"
#continue
}
[pscustomobject] @{
ID = $update.Identity.UpdateID
KB = $update.KBARticleIDs| %{ $_ }
URL = $update.MoreInfoUrls| %{ $_ }
Type = $Update.Categories | ?{ $_.Parent.CategoryID -ne "6964aab4-c5b5-43bd-a17d-ffb4346a8e1d" } | %{ $_.Name }
Title = $update.Title
Size = $bundledUpdate.MaxDownloadSize
DownloadURL = $content.DownloadURL
Auto = $update.autoSelectOnWebSites
}
}
}
}