FunctionsPublic/Get-ProxsysGraphAllUsers.ps1

<#
.SYNOPSIS
Get all users
 
.DESCRIPTION
Lists all users that are configured in the customers tenant
#>

function Get-ProxsysGraphAllUsers
{
    [cmdletbinding()]
    param(
        [psobject]$accessToken,
        [string]$tenantID
    )

    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 { getMsGraphUsers { id, name, businessPhones, givenName, mail, surname, userType, userPrincipalName }}" }

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

        $responseBody.data.getMsGraphUsers
    }
}