FunctionsPublic/Get-GraphMemberOfGroup.ps1

function Get-GraphMemberOfGroup
{
    [CmdletBinding()]
    param(
        [parameter(Mandatory=$true)][psobject]$accessToken, 
        [parameter(Mandatory=$true)][string]$groupID, 
        [parameter(Mandatory=$false)][string]$nextLink
    )
    #
    # Get all existing groups
    #
    if($nextLink.Length -eq 0)
    {
        $responseBody = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/groups/$($groupID)/members" -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"}
    }
    else
    {    
        $responseBody = Invoke-RestMethod -Uri $nextLink -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"}
    }
    
    if($null -eq $responseBody.id)
    {
        $groupsResult = $responseBody.value
    }
    else
    {
        $groupsResult = $responseBody
    }

    #
    # Retrieve additional results when there are additional results available
    #
    if($responseBody.'@odata.nextLink'.Length -gt 0)
    {
        $groupsResult += Get-GraphMemberOfGroup -accessToken $accessToken -groupID $groupID -nextLink $responseBody.'@odata.nextLink'
    }

    return $groupsResult
}