functions/Get-AzureDevOpsItems.ps1

function Get-AzureDevOpsItems {

    param(
        [Parameter(Mandatory)]
        [string]$Project,
        [Parameter(Mandatory)]
        [string]$Repository,
        [Parameter(Mandatory)]
        [string]$Path,
        [Parameter(Mandatory=$false)]
        [ValidateSet('full', 'none', 'oneLevel', 'oneLevelPlusNestedEmptyFolders')]
        [string]$RecursionLevel = 'none'
    )

    $returnObj = $null

    #Load helpers
    $helpersDirPath = Join-Path -Path $PSScriptRoot -ChildPath '..\helpers'
    . (Join-Path -Path $helpersDirPath -ChildPath 'testAzureDevOpsConnection.ps1')

    testAzureDevOpsConnection    

    $Project = $Project.ToLower().Trim()
    $Repository = $Repository.ToLower().Trim()
    $Path = $Path.ToLower().Trim()

    $incContent = $IncludeContent.IsPresent

    $uri = '{0}/{1}/_apis/git/repositories/{2}/items?scopePath={3}&recursionLevel={4}&includeContent={5}&api-version=7.1'
    $uri = ($uri -f $script:AzureDevOpsOrgUrl, $Project, $Repository, $Path, $RecursionLevel, $incContent)

    $method = 'GET'

    $headers = @{
        "Authorization" = $script:AzureDevOpsAuthHeaderValue
        "Content-Type"  = "application/json"
    }

    $response = $null
    try
    { $response = Invoke-WebRequest -Uri $uri -Method $method -Headers $headers -UseBasicParsing }
    catch 
    { $response = $null    }

    if (($response -ne $null) -and ($response.StatusCode -eq 200)) {
        $returnObj = (ConvertFrom-Json -InputObject $response.Content -Depth $script:DefaultJsonDepth )
    }

    return $returnObj
}