Public/Get-CloudLoadTestAuthHeaders.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Function Get-CloudLoadTestAuthHeaders{
[cmdletbinding()]
Param(

    [Parameter(Mandatory=$True)]
    [ValidateNotNullOrEmpty()]
    [string]
    $VisualStudioAccountName,
        
    [Parameter(Mandatory=$True)]
    [ValidateNotNullOrEmpty()]
    [string]
    $VisualStudioAccountPersonalAccessToken,

    [Parameter(Mandatory=$False)]
    [ValidateSet("1.0")]
    [string]
    $ApiVersion = "1.0"

)

    $BaseUri = "https://{0}.vsclt.visualstudio.com" -f $VisualStudioAccountName
    $AuthBase64 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(" :$VisualStudioAccountPersonalAccessToken"))
    $Headers = @{
        Authorization = "Basic $AuthBase64"
        "Content-Type" = "application/json; charset=utf-8"
        Accept = "application/json; api-version=$ApiVersion"
    }
    Return [pscustomobject]@{
        BaseUri = $BaseUri
        Headers = $Headers

    }

}