Created
April 13, 2017 12:27
-
-
Save fsackur/34df3d9a8b8f2f0c50458d6929881e06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Work in progress | |
Pull build versions into PSObjects from the super-useful https://sqlserverbuilds.blogspot.co.uk | |
#> | |
#$Blog = Invoke-WebRequest https://sqlserverbuilds.blogspot.co.uk/ | |
$TablesHtml = [regex]::Matches( | |
$Blog.RawContent, | |
( | |
'<table .+?>\n' + | |
'<tr><th>Build<th class=h>SQLSERVR.EXE Build<th>File version<th class=h>Q<th class=h>KB<th width=580>KB / Description<th width=125>Release Date</tr>' + | |
'.+?' + | |
'</table>' | |
), | |
[System.Text.RegularExpressions.RegexOptions]::Singleline | |
) | select -ExpandProperty Value | |
$Tables = @() | |
foreach ($TableHtml in $TablesHtml) { | |
$Rows = [regex]::Matches( | |
$TableHtml, | |
'<tr>.+?</tr>' | |
) | select -ExpandProperty Value | |
$HeaderRow = $Rows[0] | |
$Rows = $Rows | select -Skip 1 | |
$Headers = [regex]::Matches( | |
$HeaderRows, | |
'(?<=<th.*?>).+?(?=<)' | |
) | foreach { | |
$_.Value | |
} | |
#$Output = @() | |
foreach ($Row in $Rows[1..11]) { | |
$Properties = ` | |
[regex]::Matches( | |
$Row, | |
'(?<=<td.*?>).+?(?=<)' | |
) | foreach { | |
$_.Value -replace '^(<td.*?>)' | |
} | |
$Obj = New-Object psobject -Property @{ | |
Build = $Properties[0]; | |
FileVersion = $Properties[1]; | |
Q = $Properties[2]; | |
KB = $Properties[3]; | |
KBDescription = $Properties[4]; | |
ReleaseDate = $Properties[5]; | |
} | |
$Tables += $Obj | |
} | |
} | |
$Tables | ft |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment