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

Resources