I need a PowerShell script to get latest binary version from this archive list https://download.docker.com/win/static/stable/x86_64/
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 docker-24.0.6.zip 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.
2
Answers
docker-check.ps1:
Output:
To offer a simpler alternative to Ömer Sezer’s helpful solution, based on the observation that the version list at https://download.docker.com/win/static/stable/x86_64/ is simply being appended to, implying that the most recent recent version is listed last:
Note:
-UseBasicParsing
, which prevents parsing of the response by the obsolete Internet Explorer engine, is only required in Windows PowerShell – you can omit the parameter in PowerShell (Core) 7+.You can then download the latest version as follows:
If you don’t want to rely on the last ZIP file listed being the most recent one, replace the
$latestZipFile = ...
statement with the following, which sorts the extracted filenames by their embedded version number and picks the highest one.