public/library/Add-PSTSSecureFile.ps1

function Add-PSTSSecureFile
{
    param(
        [Parameter(Mandatory=$true)][string] $project,
        [Parameter(Mandatory=$true)][string] $name,
        [Parameter(Mandatory=$true)][string] $file
    )

    process {

        if ($(Test-Path -Path $file) -eq $false) {
            $exception = [System.Management.Automation.ItemNotFoundException]::new("the file $file could not be found")
            Throw  $exception
        }

        $content = `
        _PSTSAPI `
            -project $project `
            -resource "distributedtask/SecureFiles" `
            -method "POST" `
            -inFile $file `
            -contentType "application/octet-stream" `
            -queryParameters "name=$($name)"

        return [SecureFile]$content
    }
}