Created
April 9, 2021 18:05
-
-
Save maxkoshevoi/60d7b7910ad6ddcc6e1c9b656a8d0301 to your computer and use it in GitHub Desktop.
Download latest GitHub release via Powershell
This file contains hidden or 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
$repoName = "PowerShell/PowerShell" | |
$assetPattern = "*-win-x64.msi" | |
$extractDirectory = "C:\Users\Public\Downloads" | |
$releasesUri = "https://api.github.com/repos/$repoName/releases/latest" | |
$asset = (Invoke-WebRequest $releasesUri | ConvertFrom-Json).assets | Where-Object name -like $assetPattern | |
$downloadUri = $asset.browser_download_url | |
$extractPath = [System.IO.Path]::Combine($extractDirectory, $asset.name) | |
Invoke-WebRequest -Uri $downloadUri -Out $extractPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks your example works fine with the powershell repo but when I execute this against my private repository I get the following error on line 11
The request was aborted: The connection was closed unexpectedly.