Modules/ConvertTo-VstsAuthorizationHeader.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function ConvertTo-VstsAuthorizationHeader {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $PersonalAccessToken
    )

    $vstsAuthType = "Basic"
    $vstsBasicAuthBase64String = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($vstsAuthType):$PersonalAccessToken"))
    $vstsBasicAuthHeader = "$vstsAuthType $vstsBasicAuthBase64String"
    $requestHeaders = @{Authorization = "$vstsBasicAuthHeader"}

    Write-Output $requestHeaders
}