functions/Get-Projects.ps1

Function Get-Projects
{
    [cmdletbinding()]
    param()
    
    $uri = $CDXSERVER + "/api/projects"

    $ProjectsList = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers -ContentType "application/json" 
    Write-Verbose ( $ProjectsList | Format-Table | Out-String )

    Write-Host "Number of Projects found: " $ProjectsList.projects.count -ForegroundColor Green
    Write-Host "Project Name : Project ID" -ForegroundColor Green
    Write-Host "---------------------------" -ForegroundColor Green
    ForEach ($strProject in $ProjectsList.projects)
    {
        Write-Host "$($strProject.name) : $($strProject.id)"
    }
}