Skip to content

Instantly share code, notes, and snippets.

@praveenc
Last active January 27, 2017 23:05
Show Gist options
  • Save praveenc/609ae48723eee82aacfe3fe3c76cc48f to your computer and use it in GitHub Desktop.
Save praveenc/609ae48723eee82aacfe3fe3c76cc48f to your computer and use it in GitHub Desktop.
# Encode string to base64
# =======================
$u="username"
$p="password"
$b64 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($u+":"+$p))
# E.g. For use in Authorization Headers
#$headers = @{"Authorization"="Basic $b64";
# "Content-Type"="application/json";
# "charset"="UTF-8"}
#Invoke-RestMethod -Method GET -Uri http://localhost:15672/api/nodes -Headers $headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment