Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save karlgluck/5564361ace08d882866d1ea4ce451e53 to your computer and use it in GitHub Desktop.
One-liner for downloading from a private GitHub repository
# Fill these in with your own values
$Username = "your_username"
$Branch = "main"
$PathToFile = "README.md"
# Go to [https://github.com/settings/tokens] and add a Personal Access Token with two scopes: "repo" and "read:org"
$GitHubAuthToken = "ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Invoke-WebRequest -Method Get -Uri "https://raw.githubusercontent.com/$Username/$Repository/$Branch/$PathToFile" -Headers @{Authorization="token $GitHubAuthToken"; 'Cache-Control'='no-cache'} | ForEach-Object { $_.Content } | Write-Host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment