I’ve been using some piece of code on WSUS to enrich non-security updates to help me identify what problem they address.
Let’s first have a look at the result as a picture is worth a thousand words 😀
Now, let’s see the code
(Get-WsusServer).SearchUpdates('Windows 7')| Where { | |
(-not($_.IsSuperseded)) -and | |
($_.Title -match "x64") -and | |
# ($_.UpdateClassificationTitle -eq "Security Updates") -and | |
(-not($_.isApproved)) -and | |
($_.IsLatestRevision) -and | |
(-not($_.isDeclined)) -and | |
($_.Title -notmatch '.NET Framework 4') -and | |
($_.Title -notmatch 'Internet Explorer (9|10)') | |
} | ForEach-Object { | |
$update = $_ | |
$TitleLine = $pageTitle = $URL = $null | |
try { | |
$URL = ($_ | Select -expand AdditionalInformationUrls) -replace 'http://support\.microsoft\.com/kb', | |
'https://support.microsoft.com/api/content/kb' | |
Write-Verbose -Message "Downloading from $($URL)" -Verbose | |
$TitleLine = (new-object Net.Webclient).DownloadString([system.Uri]$($URL)) -split '\<' | | |
Select-string -Pattern 'h1.*title\=' -ErrorAction Stop | Select -Expand Line | |
if ($TitleLine) { | |
$pageTitle = ([regex]'h1\sid\=".*"\s*title\="(?<Title>.*)"\s*class=').Matches($TitleLine) | | |
Select -Last 1 -expand Groups | Select -Last 1 -Expand Value | |
$_ | Add-Member -MemberType NoteProperty -Name "Page Title" -Value $pageTitle -Force -PassThru -ErrorAction Stop | |
} else { | |
Write-Warning -Message "Failed to find title for $($update.Title)" | |
$update | Add-Member -MemberType NoteProperty -Name "Page Title" -Value $($update.Description) -Force -PassThru | |
} | |
} catch { | |
Write-Warning -Message "Failed for $($update.Title) because $($_.Exception.Message)" | |
$update | Add-Member -MemberType NoteProperty -Name "Page Title" -Value $($update.Description) -Force -PassThru | |
} | |
} | Select Title,State,'Page Title' | Out-GridView |
I wanted to share this a long time ago but the initial piece of code broke while Microsoft was upgrading their support.microsoft.com website.
It may broke again of course…