Invoke-SBRDownload.ps1

function Invoke-SBRDownload(){
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory=$true)]
        [string] $ApiBaseUrl,

        [Parameter(Mandatory=$true)]
        [string] $ApiKey,

        [Parameter(Mandatory=$true)]
        [guid] $AgentUID
    )

    $TempZipFile = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath ([System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetTempFileName()) + ".zip")

    Invoke-RestMethod -Uri "$ApiBaseUrl/api/SBRAgents/$($AgentUID)/Download" `
                      -Method Post `
                      -OutFile $TempZipFile `
                      -Headers @{"Authorization" = "Bearer " + $ApiKey} 

    return $TempZipFile
}