Returning multiple pages in MS Graph query


I’m having trouble getting a list of applications registered in Azure by querying the MS Graph API. The issue is the paging limitation. I’ve got 157 applications registered in Azure, but the script is only returning the last 57. I know the page limit is 100 by default, so I know WHY it’s doing it, but I can’t seem to get around it. I’ve played around with “@odata.nextlink”, but I can’t seem to get it to work properly, it still only returns the second page of data. Here’s the relevant code:


$url = “,displayname

do {

$response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method GET -ContentType “application/json”
if ($response.Content)
$content = $response.Content | ConvertFrom-Json

$value = $content.value

$count = $value.count

Write-Host $response

Write-Host $value

Write-Host “$iCount || $count”

$nextLink = $content.’@odata.nextLink

$url = $nextLink

} else {


} while ($nextLink -ne $null)


I know I left out all of the oauth token and header information, but that’s not where the issue is.

Any suggestions would be greatly appreciated.


Have you tried using the $top={n} in your url query?

There is also a website to test your queries against the graph API.

Graph Explorer


Thanks for your response. I ran the query URL through Graph Explorer, and it did come back with all of the results. Turns out the issue was in the Do…While loop I was running. I wasn’t dumping the results out after each loop of the script, so it only caught the last iteration.

Thanks again for the suggestion.