--- title: "Audit SharePoint Files with URLs Exceeding a Length Threshold" slug: "dex-wf-audit-sharepoint-long-urls" updated: 2026-11-30T16:12:59Z published: 2026-11-30T16:12:59Z canonical: "documentation.sysaid.com/dex-wf-audit-sharepoint-long-urls" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.sysaid.com/llms.txt > Use this file to discover all available pages before exploring further. # Audit SharePoint Files with URLs Exceeding a Length Threshold Identify files whose full web URL approaches SharePoint and OneDrive sync limits, and export them for remediation. **Complexity:** Intermediate. **Impact:** governance + sharepoint + audit + reporting. ## Why use this workflow SharePoint Online and OneDrive for Business enforce a limit of **400 characters** on the combined path and file name for any item. Files that approach or exceed this limit can cause the OneDrive sync client to refuse to sync them, Office desktop apps to fail to open them, Power Automate flows to break, and migration tools to skip them. SharePoint web URLs encode the site, library, folder hierarchy, and file name, so deeply nested folder structures or long file names can breach the threshold. Auditing your tenant for files whose `webUrl` exceeds a safe threshold (for example **390 characters**, a small buffer below the 400 limit) lets you remediate before users file tickets. Run this audit: - Quarterly as part of SharePoint governance - Before a tenant-to-tenant migration or domain rename - When investigating OneDrive sync failures for a specific user or site - Before enabling new retention or sensitivity labels that may further extend paths ## Expected outcomes - A CSV report listing every file whose `webUrl` exceeds the configured threshold (default 390 characters) - Each row includes file name, URL length, site display name, document library, and the full web URL - A prioritized remediation target list showing the folders or libraries that contribute the most over-limit items - Evidence for driving a naming-convention or folder-depth policy with content owners ### Typical remediation actions 1. Shorten the deepest folder names (often date-based or project-code folders). 2. Flatten folder hierarchies by moving files up one or two levels. 3. Rename files to remove redundant prefixes. 4. Educate site owners on the 400-character path limit. ## Risks and considerations - **Read-only audit.** This workflow only enumerates and reports. It does not rename or move files. Coordinate remediation with content owners. - **Renaming breaks existing links.** If you rename folders, shared links, bookmarks, or embedded references that point to the old path can return 404. Use *Move* rather than *Rename* where possible. - **Tenant scan cost.** On large tenants (thousands of sites) a full scan can generate heavy Graph traffic. Use the per-site mode when you only need to audit one collection. - **Delta endpoint behavior.** The `/drives/{id}/root/delta` endpoint is used for efficient enumeration. On the first call it returns the full tree, so initial runs are the slowest. - **Personal OneDrive sites.** Personal (`/personal/`) sites are included by the `/sites?search=*` query only in limited cases. To audit OneDrive explicitly, enumerate `/users/{id}/drive` instead. - **Throttling.** Expect HTTP 429 responses on large tenants. Respect the `Retry-After` header. ## Required permissions | Permission | Why it's needed | | --- | --- | | Sites.Read.All | Enumerate all SharePoint sites in the tenant | | Files.Read.All | Read file metadata (name, webUrl, size) across all drives | | User.Read.All | Optional: required only when explicitly auditing personal OneDrive sites via /users/{id}/drive | ## Ask Dex Paste the prompt into a Dex conversation. ### Prompt for IT admins ``` Scan our SharePoint tenant for any file whose web URL exceeds {threshold} characters (default 390). Enumerate every site and document library, collect the over-limit items, and produce a CSV report with file name, URL length, site, library, and full web URL - sorted longest URL first. Flag the sites and folders contributing the most over-limit items so we can prioritize remediation. ``` ## Manual steps (admin center) The SharePoint admin center has no built-in report that filters files by URL length, so the manual path is a hybrid: generate an inventory, then filter in Excel. ### Step 1: Open the SharePoint admin center Sign in to the [Microsoft 365 admin center](https://admin.microsoft.com) as a Global or SharePoint Administrator, then go to **Admin centers** > **SharePoint** > **Reports** > **Data access governance**. ### Step 2: Pull a site-level inventory From the Data access governance hub, export the *Sites with shared content* or *Permissions* report for the site collection you want to audit. These exports give you site and link metadata, not per-file URL lengths. ### Step 3: Export a file inventory from the target site 1. Go to the affected site in SharePoint. 2. Open the document library in classic view. 3. Click **Library** > **Export to Excel** (or, for modern libraries, open the library in Files Explorer view and copy the list). 4. In Excel, add a column with the formula `=LEN([@Path])` and filter for values greater than 390. ### Step 4: Review and flag Share the filtered list with the site owner and agree on a remediation plan (rename, move, or archive). ### Limitation The manual path works for a single library but does not scale to a tenant-wide audit. For anything beyond one site, use the Graph API or PowerShell approach. ## Microsoft Graph API No single Graph endpoint filters by URL length, so the pattern is: enumerate sites, enumerate drives, enumerate items (using the delta endpoint), then filter client-side on `webUrl.length`. ### Step 1: List all SharePoint sites ``` GET https://graph.microsoft.com/v1.0/sites?search=*&$top=999 Authorization: Bearer {access_token} ``` The response contains an array of site objects. Capture each `id`. ### Step 2: List drives (document libraries) for each site ``` GET https://graph.microsoft.com/v1.0/sites/{site-id}/drives ``` ### Step 3: Enumerate items using the delta endpoint The `delta` endpoint returns all items in the drive across paginated responses, and supports a small `$select` projection so you don't fetch unnecessary fields. ``` GET https://graph.microsoft.com/v1.0/drives/{drive-id}/root/delta?$select=name,webUrl,file ``` Example response (truncated): ``` {  "value": [    {      "name": "2024-Q4-Reconciliation-Draft-v7-FINAL.xlsx",      "webUrl": "https://contoso.sharepoint.com/sites/Finance/Shared%20Documents/...",      "file": { "mimeType": "application/vnd.ms-excel" }    }  ],  "@odata.nextLink": "https://graph.microsoft.com/v1.0/drives/.../root/delta?token=..." } ``` ### Step 4: Filter client-side For each item where `file` is present (that is, it is not a folder) and `webUrl.length > 390`, record the item. Follow `@odata.nextLink` until no more pages remain. ### Throttling On HTTP 429 responses, honor the `Retry-After` header. On very large tenants, consider running the scan per site in parallel batches. ## PowerShell The approach uses the Microsoft Graph PowerShell SDK to enumerate every site and drive in the tenant, walk each drive through the delta endpoint, and export a CSV of files whose `webUrl` exceeds the threshold. ### Prerequisites - PowerShell 7 or later - `Microsoft.Graph` module: `Install-Module Microsoft.Graph -Scope CurrentUser` - An account with **Sites.Read.All** and **Files.Read.All** consented ### Approach 1. Connect to Graph with the required read scopes. 2. List all sites with `Get-MgSite -Search '*'`. 3. For each site, enumerate its document libraries (drives). 4. For each drive, walk the full item tree using `/drives/{id}/root/delta`. 5. Keep items where `webUrl.Length` exceeds a `Threshold` value (default 390). 6. Write the results to CSV and print a summary.