Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll
Created November 24, 2015 20:43
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save p0w3rsh3ll/0359fc67758196703d96 to your computer and use it in GitHub Desktop.
(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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment