I want to find download URL for the latest version of Cura right now it is (https://github.com/Ultimaker/Cura/releases/download/5.2.1/Ultimaker-Cura-5.2.1-win64.exe)
and I have written
(Invoke-WebRequest -Uri "https://ultimaker.com/software/ultimaker-cura").innerHTML -match "(https*.exe)"
I tried it with .innerHTML or usebasicparsing or Invoke-Restmethod and I could not find it, can someone help me to find it?
thanks in advance
CodePudding user response:
I would suggest you to use the release API from GitHub to find out the latest release of the software.
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/Ultimaker/Cura/releases/latest"
$windowsRelease = $response.assets | Where-Object { $_.name -match "win64" }
Please note that I am applying a Where-Object
here to filter out only win64
, because a release can contain binary for different platforms.
Then you can use browser_download_url
property to get the download url which you can use it along side with Invoke-WebRequest
to download it
# download the file
Invoke-WebRequest $windowsRelease.browser_download_url -OutFile "CuraLatest.exe"
CodePudding user response:
Good day
When I try to download files from Powershell I use this:
$source = "https://github.com/Ultimaker/Cura/releases/download/5.2.1/Ultimaker-Cura-5.2.1-win64.exe"
$destination = "your download folder path"
#Using Webclient
$wc = [System.Net.WebClient]::new()
$wc.DownloadFile($source,$destination)
It's a simple way to use .Net to download files