Last active
May 13, 2025 01:42
-
-
Save rithala/050a16dd31a13e6d7e3c335358fcfade to your computer and use it in GitHub Desktop.
PowerShell HTTP Request with Basic Auth
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
| $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