Skip to content

Instantly share code, notes, and snippets.

View sonibla's full-sized avatar

Alban sonibla

  • Lille University
  • Lille, France
View GitHub Profile
@sonibla
sonibla / download-github-private-asset.ps1
Created November 29, 2021 10:39
Download assets from private Github releases using PowerShell
$credentials="<github_access_token>"
$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 = "https://api.github.com/repos/$repo/releases"
Write-Host Determining latest release
$id = ((Invoke-WebRequest $releases -Headers $headers | ConvertFrom-Json)[0].assets | where { $_.name -eq $file })[0].id