Functions/Systems/Get-WindowsUpdateList.ps1
function Get-WindowsUpdateList { [CmdletBinding()] Param () Process { # Invoke Session to Update Service $Session = New-Object -ComObject "Microsoft.Update.Session" $Searcher = $Session.CreateUpdateSearcher() $historyCount = $Searcher.GetTotalHistoryCount() $UpdateHistory = $Searcher.QueryHistory(0, $historyCount) # Order KBs based on History Query $KBs = foreach ($Update in $UpdateHistory) { [regex]::match($Update.Title,'(KB[0-9]{6,7})').value | Where-Object {$_ -ne ""} | foreach { [pscustomobject]([ordered]@{ KB = $_ Title = $Update.Title Description = $Update.Description Date = $Update.Date }) } } #Output KBs $KBs } End {$KBs | sort KB} } |