FunctionsPublic/Get-ProxsysGraphAllTenants.ps1

<#
.SYNOPSIS
Get all tenants
 
.DESCRIPTION
Lists all tenants that are configured within the CDI
#>

function Get-ProxsysGraphAllTenants
{
    [cmdletbinding()]
    param(
        [psobject]$accessToken
    )

    process
    {
        if($null -eq $accessToken)
        {
            Write-Error "Invalid input received. Please specify all parameters in order to use this function."
            return $null
        }

        $requestBody = @{ "query" = "query { tenants { id, name }}" }

        $responseBody = Invoke-RestMethod `
            -Uri "https://graph.proxsys.dev/graph"  `
            -Headers @{
                "Authorization" = "Bearer $($accesstoken.AccessTokenCredential.GetNetworkCredential().password)"
            } `
            -Body $requestBody `
            -ContentType "application/json"

        $responseBody.data.tenants
    }
}