Skip to content

Instantly share code, notes, and snippets.

@ZJPat
Created July 4, 2024 04:03
Show Gist options
  • Save ZJPat/6d97235c1d174cd9de4a9411143750b4 to your computer and use it in GitHub Desktop.
Save ZJPat/6d97235c1d174cd9de4a9411143750b4 to your computer and use it in GitHub Desktop.
Scrap EntraAD for the latest Version and release date
<# Based on https://old.reddit.com/r/PowerShell/comments/n686f4/web_scraping_and_building_a_table_better_methods/
Base usage at a MSP to keep track of the latest version in case autodl fails. #>
[Net.ServicePointManager]::SecurityProtocol = [Enum]::ToObject([Net.SecurityProtocolType], 3072)
$URI = "https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/reference-connect-version-history"
$webclient = New-Object System.Net.WebClient
$result = $webclient.DownloadString($URI)
$versions = @()
switch -Regex ($result -split '(?=<h2)' | Out-String -Stream) {
'<h2.+?>(.+?)</h2>' {
$version = $Matches.1
}
'<p>(\d{1,2}/\d{1,2}/\d{4}|(?:\d{1,2}\s+[A-Za-z]+\s+\d{4})):' {
$versions += [PSCustomObject]@{
Version = $version
Date = $Matches.1
}
}
}
$versions | Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment