--- title: "Audit SharePoint Files with Public or Anonymous Sharing Links" slug: "dex-wf-audit-sharepoint-anonymous-links" updated: 2026-11-30T16:12:58Z published: 2026-11-30T16:12:58Z canonical: "documentation.sysaid.com/dex-wf-audit-sharepoint-anonymous-links" --- > ## 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 Public or Anonymous Sharing Links Scan every SharePoint site and document library to identify files exposed through anonymous (public) sharing links and produce a remediation-ready report. **Complexity:** Intermediate. **Impact:** security + compliance + data-governance + access-review. ## Why use this workflow Anonymous sharing links in SharePoint (also called *"Anyone" links*) allow access to files without authentication: anyone with the URL can view or edit the content. These links are a common source of data leakage in Microsoft 365 tenants. Run this audit when you need to: - Respond to a compliance review (SOC 2, ISO 27001, HIPAA, GDPR) - Investigate a suspected data exposure incident - Perform a quarterly or post-acquisition data governance review - Validate external sharing policy changes after tightening tenant-level settings - Prepare for a tenant-to-tenant migration or M&A due diligence The workflow walks every SharePoint site collection, enumerates each document library, inspects file-level sharing permissions, and flags items where the sharing `scope` is `anonymous` (and, optionally, `organization` for a broader posture review). ## Expected outcomes - A complete inventory of files with **anonymous** (public internet) sharing links across all SharePoint sites - A secondary list of files with **organization-wide** links (optional but recommended) - A CSV report with site, file path, link type, permission scope, and direct URL, suitable for import into a GRC tool or ticketing system - Remediation targets: each flagged file can be revoked or re-shared with specific users - A repeatable script you can schedule to catch new exposures ## Risks and considerations - **Read-only audit:** The audit does not change any permissions. Do not revoke sharing links without a review, because you may break legitimate external workflows (partners, contractors, customers). - **Throttling:** Large tenants can hit Graph API throttling (HTTP 429). Honor `Retry-After` headers and paginate with `@odata.nextLink`. - **Permission inspection is per item:** The `shared` property on a `driveItem` indicates *that* it is shared, not *how*. Call `GET /drives/{id}/items/{id}/permissions` to confirm that a link is anonymous. - **Nested folders:** `/root/children` returns only top-level items. Use `/root/search(q=' ')` or recurse into folders to cover every file. - **OneDrive is separate:** This workflow targets SharePoint sites. To scan OneDrive personal libraries, use `/users/{id}/drive`. - **Data handling:** The output report contains file paths and URLs that may be sensitive. Store it in a restricted location and delete it after remediation. - **Scopes:** `anonymous` means public internet, `organization` means anyone in the tenant with the link, and `users` means specific named users. Only `anonymous` is a public exposure. ## Required permissions | Permission | Why it's needed | | --- | --- | | Sites.Read.All | Enumerate all SharePoint sites and read site metadata | | Files.Read.All | List drive items across all document libraries | | Sites.FullControl.All | Required to read detailed sharing permissions on every item (Files.Read.All alone is insufficient for /permissions on some items) | ## Ask Dex Paste the prompt into a Dex conversation. ### Prompt for IT admins ``` Audit all SharePoint sites in our tenant for files shared via anonymous (public) links. Walk every site and document library, check file-level sharing permissions, and produce a CSV report listing each exposed file with its site, path, URL, and link details. Optionally include organization-wide links as a secondary finding. ``` ## Manual steps (admin center) Three interface-based options are available. The Microsoft Purview option covers the whole tenant. The SharePoint admin center option suits a smaller tenant. ### Option A: SharePoint admin center (per-site review) 1. Sign in to the SharePoint admin center at `https://<tenant>-admin.sharepoint.com` as a Global Administrator or SharePoint Administrator. 2. Go to **Sites** > **Active sites**. 3. For each site, click the site name, then open **Policies** > **Sharing** to confirm whether the site allows *Anyone* links. If it does not, the site cannot have public links. 4. Open the site in a new tab. For each document library, go to **Settings** > **Library settings** > **More library settings** > **Permissions for this document library**. 5. Click **Manage access requests**, or use **Advanced** > **Check Permissions** on individual files. Files with an "Anyone" link show a sharing link entry with no grantee. ### Option B: Microsoft Purview content search (tenant-wide) 1. Open [Microsoft Purview](https://purview.microsoft.com). 2. Go to **Solutions** > **eDiscovery** > **Content search** (or **Data Lifecycle Management** > **Content search**, depending on your license). 3. Click **New search** and give it a name such as `Public SharePoint Files Audit`. 4. Under **Locations**, choose **SharePoint sites** > **All**. 5. In the query box, enter KQL: `SharedWithUsersOWSUser:"Everyone" OR ViewableByExternalUsers:true OR IsAnonymousAccess:true` 6. Run the search and wait for it to complete. 7. Click **Export results** > **Reports only** to download a CSV of matching items. ### Option C: SharePoint sharing report (built-in, per-site) 1. Open a SharePoint site as a site owner. 2. Go to **Settings** > **Site contents** > **Site usage**. 3. Scroll to **Shared with external users** and click **Run sharing report**. 4. Choose a target library to save the CSV into and click **Run report**. The CSV lists every externally shared item, including anonymous links. 5. Repeat for each site. For tenants with many sites, use the API or script approach. ## Microsoft Graph API No single endpoint returns all publicly shared files tenant-wide. Walk the hierarchy (sites, drives, items, permissions) and filter on `link.scope == 'anonymous'`. ### Step 1: List all SharePoint sites ``` GET https://graph.microsoft.com/v1.0/sites?search=*&$select=id,displayName,webUrl&$top=999 Authorization: Bearer ``` Paginate with `@odata.nextLink` until exhausted. ### Step 2: List document libraries (drives) for each site ``` GET https://graph.microsoft.com/v1.0/sites/{site-id}/drives?$select=id,name ``` ### Step 3: Enumerate all files in each drive (including subfolders) Use the `search` endpoint with an empty-ish query to return every item: ``` GET https://graph.microsoft.com/v1.0/drives/{drive-id}/root/search(q=' ')?$select=id,name,webUrl,shared,file,parentReference&$top=200 ``` Items with a `shared` property are candidates. The `shared.scope` value on the `driveItem` can be `anonymous`, `organization`, or `users`, and may be absent even when an anonymous link exists, so verify through `/permissions`. ### Step 4: Inspect sharing permissions on each candidate item ``` GET https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{item-id}/permissions ``` Example response fragment for an anonymous link: ``` {  "id": "aTowIy5mfG1lbWJlcnNoaXB...",  "roles": ["read"],  "link": {    "scope": "anonymous",    "type": "view",    "webUrl": "https://tenant.sharepoint.com/:b:/s/Site/Ab12...",    "preventsDownload": false  } } ``` Any permission object where `link.scope == "anonymous"` is a public sharing link and belongs in the report. ### Step 5: (Optional) Remove an anonymous link After review: ``` DELETE https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{item-id}/permissions/{permission-id} ``` ### Rate limits For large tenants, batch with `$batch` (up to 20 requests) and respect `Retry-After` on 429 responses. ## PowerShell The approach uses the **Microsoft.Graph** PowerShell module to run the audit and write a CSV report, handling pagination, throttling, and folder recursion. ### Prerequisites - PowerShell 7 or later recommended - Install the Graph SDK: `Install-Module Microsoft.Graph -Scope CurrentUser` - Connect with the required scopes (see the permissions table) ### Approach 1. `Connect-MgGraph` authenticates with delegated or app-only credentials. 2. `Get-MgSite -Search '*'` enumerates every SharePoint site. 3. For each site, `Get-MgSiteDrive` lists document libraries. 4. For each drive, call the `search(q=' ')` endpoint to reach every item. 5. For every item with a `shared` hint, pull `/permissions` and keep only those where `link.scope == 'anonymous'`. 6. Write the results to a timestamped CSV, with a summary of sites scanned, files checked, and public links found.