I am following the example provided in this entry on how to manually build a header to be used on a Invoke-WebRequest.
The sample solution given in the said entry is:
$user = 'user'
$pass = 'pass'
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
}
Invoke-WebRequest -Uri 'https://whatever' -Headers $Headers
I am having trouble concatenating $user and $pass because the value of $pass contains a double-quote.
How do I correctly concatenate these variables?