Last active
November 6, 2023 09:06
-
-
Save rithala/050a16dd31a13e6d7e3c335358fcfade to your computer and use it in GitHub Desktop.
PowerShell HTTP Request with Basic Auth
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
$user = 'user' | |
$pass = 'pass' | |
$uri = '<url>' | |
$pair = "$($user):$($pass)" | |
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) | |
$basicAuthValue = "Basic $encodedCreds" | |
$Headers = @{ | |
Authorization = $basicAuthValue; | |
Accept = 'application/json' | |
} | |
Invoke-WebRequest -Uri $uri -Headers $Headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment