Guest User

Untitled

a guest
Nov 24th, 2017
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. $user = "USERNAME"
  2. $pass = "PASSWORD"
  3. $pair = "${user}:${pass}"
  4.  
  5. #Encode the string to the RFC2045-MIME variant of Base64, except not limited to 76 char/line.
  6. $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
  7. $base64 = [System.Convert]::ToBase64String($bytes)
  8.  
  9. #Create the Auth value as the method, a space, and then the encoded pair Method Base64String
  10. $basicAuthValue = "Basic $base64"
  11.  
  12. #Create the header Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
  13. $headers = @{ Authorization = $basicAuthValue }
  14.  
  15. #Invoke the web-request
  16. Invoke-WebRequest -uri $uri -Headers $headers
Add Comment
Please, Sign In to add comment