Created
May 14, 2022 17:32
-
-
Save karlgluck/5564361ace08d882866d1ea4ce451e53 to your computer and use it in GitHub Desktop.
One-liner for downloading from a private GitHub repository
This file contains 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
# 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