Created
August 18, 2017 22:28
-
-
Save fijiaaron/13ac0efd8fa99a6fa559130c0d22c1ed to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$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