public/git/Get-PSTSGitRepositoryItemFolder.ps1

function Get-PSTSGitRepositoryRefItemFolder
{
    param(
         [Parameter(Mandatory=$true)][string] $project,
         [Parameter(Mandatory=$true)][string] $repository,
         [Parameter(Mandatory=$true)][string] $branch,
         [Parameter(Mandatory=$true)][string] $folderPath
    )

    process {

        $id=Get-PSTSGitRepository -project $project | Where-Object { $_.name -eq $repository } | Select-Object -ExpandProperty id

        if ($null -eq $id) {
            throw [exception]::new("repository Id for $repository could not be found")
            return
        }

        $content = `
        _PSTSAPI `
            -resource "git/repositories/$id/items" `
            -method "GET" `
            -project $project `
            -apiVersion "api-version=5.0-preview.1" `
            -queryParameters "Scopepath=/$($filePath)&versionDescriptor[version]=$($branch)&includeContent=true&download=false&resolveLfs=true&includeContentMetadata=true"

        return [GitItem[]]$content.Value
    }
}