๐Ÿ“ Recipe ยท SharePoint & OneDrive

Report SharePoint Sites with File Counts and Storage Usage

Inventory every SharePoint site in your tenant with item counts and storage consumption in MB

Complexity

Intermediate

Impact

read-only + reporting + capacity-planning + sharepoint + audit

Context

Why This Matters

SharePoint storage in Microsoft 365 is a finite, paid resource. Tenants receive a base allocation (typically 1 TB + 10 GB per licensed user) plus any add-on storage SKUs. Over time, abandoned team sites, video-heavy document libraries, and legacy migration landing zones can silently consume that pool โ€” leading to surprise overage charges, failed uploads, and user-facing errors like Storage quota exceeded.

This recipe produces a tenant-wide inventory of every SharePoint site with two key metrics per site: item count (files and folders at the root level of the default document library) and storage used in MB. Run it as part of a quarterly capacity review, before purchasing additional SharePoint storage, or when investigating which sites are driving growth. The report is also useful during mergers, divestitures, and data-lifecycle audits where you need to justify retention or archival decisions.

Expected Outcomes

What you'll have when you finish

  • A sorted list of every SharePoint site in the tenant (communication sites, team sites, the root site, hub sites, and the Content Type Hub).
  • Storage consumed per site in megabytes, pulled from the drive quota.used property or the root folder size.
  • File/folder count at the default document library root for each site.
  • A grand total of storage used across the tenant.
  • Exportable CSV output for capacity planning, chargeback, or executive reporting.

Risks & Considerations

Things to watch out for

  • Permissions: Sites.Read.All is required to enumerate all sites. The /sites/getAllSites endpoint is inconsistent and often returns 403 โ€” use /sites?search=* instead.
  • Root-level counts only: folder.childCount at the root is not a recursive file count. Sites with nested folders will under-report unless you recurse or use the SharePoint admin Usage report.
  • Quota data is eventually consistent: The quota.used value on a drive can lag by several hours. For exact chargeback numbers, cross-reference with the SharePoint admin center's Active Sites report.
  • Throttling: Large tenants (1000+ sites) will hit Graph throttling (HTTP 429). Add retry-with-backoff logic and respect the Retry-After header.
  • Personal OneDrive sites are excluded by the search endpoint by default. If you need them, query /users/{id}/drive separately.
  • Don't modify: This is a read-only audit. Do not combine with bulk-delete operations without an explicit owner sign-off and a recycle-bin retention check.

Required Permissions

PermissionWhy It's Needed
Sites.Read.AllRequired to enumerate every SharePoint site in the tenant and read its metadata.
Files.Read.AllRequired to read drive and driveItem properties (size, childCount, quota) across all sites.
Reports.Read.AllOptional โ€” needed if you pull storage data from the SharePoint Usage reports instead of per-drive quota.

The fastest way to get this done โ€” just ask Dex. Copy the prompt below and paste it into your Dex conversation.

For IT Admins

Paste into Dex CoAdmin

List all SharePoint sites in the tenant with the number of files at each site's document library root and the total storage used in MB. Sort by size descending and include the grand total.
Try in Dex CoAdmin