functions/Get-Projects.ps1

<#
.SYNOPSIS
 
Retrieves the priveleged projects from the server.
 
.DESCRIPTION
Retrieves the priveleged projects from the server and returns the result as projectname:ProjectID pairs.
 
.EXAMPLE
 
Number of Projects found: 2
project1:1
project2:2
 
#>


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)"
    }
}