Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fijiaaron/13ac0efd8fa99a6fa559130c0d22c1ed to your computer and use it in GitHub Desktop.
Save fijiaaron/13ac0efd8fa99a6fa559130c0d22c1ed to your computer and use it in GitHub Desktop.
$username = $(Get-ChildItem Env:USERNAME).value
$password = $(Get-ChildItem Env:PASSWORD).value
$credentials = "$username`:$password"
$encodedCredentials = `
[System.Convert]::ToBase64String( `
[System.Text.Encoding]::ASCII.GetBytes($credentials))
Invoke-WebRequest `
-Uri https://api.example.com/some/endpoint `
-Headers @{ Authorization = "Basic $encodedCredentials" }
$response = $(Invoke-WebRequest -Uri "$endpoint" -Headers $headers)
$data = $(ConvertFrom-Json -InputObject $response.Content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment