Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Download assets from private Github releases using PowerShell
$repo = "<user_or_org>/<repo_name>"
$file = "<name_of_asset_file>"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "token $credentials")
$releases = "$repo/releases"
Write-Host Determining latest release
$id = ((Invoke-WebRequest $releases -Headers $headers | ConvertFrom-Json)[0].assets | where { $ -eq $file })[0].id
$download = "https://" + $credentials + "$repo/releases/assets/$id"
Write-Host Dowloading latest release
$headers.Add("Accept", "application/octet-stream")
Invoke-WebRequest -Uri $download -Headers $headers -OutFile $file
Write-Host Extracting release files
Expand-Archive $file -Force
Write-Host Cleaning up target dir
Remove-Item "$file" -Force
Copy link

sonibla commented Nov 29, 2021

Copy link

Silloky commented Jul 24, 2022

@sonibla Thank you SO much for this script ! Have been looking for the last 3 hours, and couldn't find anything suitable ! But yours is simply a lifesaver ! Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment