How to get latest binary version from Archieve using Powershell

I need a PowerShell script to get latest binary version from this archive list

So as when I run the script, it checks for latest zip and returns me latest version number and link to download. For example, if latest file is then I need

  • 24.0.6
  • link to that zip which ultimately I can use to download

I have subsequent script to utilize that zip but I have never tried getting it from an archive url.

>Solution :


$archiveUrl = ""

$response = Invoke-WebRequest -Uri $archiveUrl

$pattern = '<a href="([^"]*docker-([\d.]+)\.zip)"'
$matches = [regex]::Matches($response.Content, $pattern)

$latestVersion = $null
$latestDownloadLink = $null

foreach ($match in $matches) {
    $downloadLink = $match.Groups[1].Value
    $version = $match.Groups[2].Value

    if ($latestVersion -eq $null -or [Version]$version -gt [Version]$latestVersion) {
        $latestVersion = $version
        $latestDownloadLink = $downloadLink

if ($latestVersion -ne $null -and $latestDownloadLink -ne $null) {
    Write-Host "Latest Version: $latestVersion"
    Write-Host "Download Link: $archiveUrl$latestDownloadLink"
} else {
    Write-Host "Unable to find the latest version and download link."


enter image description here

Leave a Reply