Private/Get-JenkinsRequestHeaders.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function Get-JenkinsRequestHeaders {
    param (
        [Parameter(Mandatory)]
        [string]
        $Username,
        [Parameter(Mandatory)]
        [securestring]
        $password
    )

    $basicAuthCreds = ConvertTo-BasicAuth   -Username $Username `
                                            -Password $password
    $crumbHeader = Get-CrumbHeader          -Username $Username `
                                            -Password $password

    $headers = @{ 'Authorization' = "Basic $basicAuthCreds" }
    $headers += ($crumbHeader | ConvertFrom-StringData)

    return $headers
}