Forum Discussion

AP_TC_ECASD's avatar
AP_TC_ECASD
Brass Contributor
Aug 06, 2025

Get-MgBookingsBusiness/Graph API Pagination Limits = 1000

Has anyone had success pulling all Bookings Businesses of their tenant over 1000?  I cannot for the life of me figure out how to get past 1000 results because there are. 

# Make sure you're connected
# Connect-MgGraph -Scopes "Bookings.Read.All"

$uri = "https://graph.microsoft.com/v1.0/solutions/bookingBusinesses"
$allBusinesses = @()

Write-Host "🔄 Starting paged retrieval..."

do {
    # Send GET request
    $response = Invoke-MgGraphRequest -Method GET -Uri $uri

    # Extract raw JSON
    $json = $response | ConvertTo-Json -Depth 10
    $parsed = $json | ConvertFrom-Json

    # Add current page of businesses
    $allBusinesses += $parsed.value

    Write-Host "  Retrieved $($parsed.value.Count) businesses..."

    # Next page URL if available
    $uri = $parsed.'@odata.nextLink'
}
while ($null -ne $uri)

Write-Host "âś… Total retrieved: $($allBusinesses.Count)"

# Export to CSV properly
$desktopPath = [Environment]::GetFolderPath("Desktop")
$exportPath = Join-Path $desktopPath "all_bookings_full.csv"

# Choose specific fields to export (optional - improves readability)
$allBusinesses |
    Select-Object id, displayName, email, phone, address |
    Export-Csv -Path $exportPath -NoTypeInformation -Encoding UTF8

Write-Host "âś… Exported clean data to: $exportPath"

 

2 Replies

  • Bart_Pasmans's avatar
    Bart_Pasmans
    Copper Contributor

    Hi AP_TC_ECASD​,

    You could also try the PowerShell Graph SDK if you want to:

    https://learn.microsoft.com/en-us/powershell/microsoftgraph/get-started?view=graph-powershell-1.0

    This will handle pagination for you automatically if I'm not mistaken. If you run into retries, time-outs etc. this abstraction will also take care of it for you. 

     

    You can use: 

    $allBusinesses = Get-MgBookingBusiness -All

    To get the bookings. See:

     

    https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.bookings/get-mgbookingbusiness?view=graph-powershell-1.0

     

    My gut feeling says you might be running into either Rate limiting somehow, or something with the token doing the API call.

     

    Kind regards,

    Bart

     

     

Resources