MS Graph API Paging Function

It shouldn’t be something new that I love to work with Graph API, so I am doing that very often.

So when getting Azure Resources via Graph API, you will immediately face the Paging topics.

You can read some Details here: Paging in Microsoft Graph REST API – TechGuy

So, nearly every Powershell Script, working with Graph API, needs Paging to get more than 100 Resources. So, I made a simple function you can use and paste into your Scripts instead of writing many lines every time.

The Code

function Get-AzureResourcePaging {
    param (
    # List Get all Apps from Azure

    $Response = Invoke-RestMethod -Method GET -Uri $URL -Headers $AuthHeader
    $Resources = $Response.value

    $ResponseNextLink = $Response."@odata.nextLink"
    while ($ResponseNextLink -ne $null) {

        $Response = (Invoke-RestMethod -Uri $ResponseNextLink -Headers $AuthHeader -Method Get)
        $ResponseNextLink = $Response."@odata.nextLink"
        $Resources += $Response.value
    return $Resources


The full Script with more Details can be found on my GitHub Repo; Seidlm/PowerShell-Templates: PowerShell Template – Logging Function (

Michael Seidl aka Techguy
au2mate everything

Leave a Comment

Your email address will not be published. Required fields are marked *