The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Use the SharePoint Online PowerShell data access governance reports to identify anonymous (“Anyone”) sharing, then remediate it by adjusting sharing settings or permissions.
- Connect to SharePoint Online PowerShell
- Install and import the SharePoint Online Management Shell if not already installed.
- Run:
Connect-SPOService -Url https://<tenant>-admin.sharepoint.com
- Report on “Anyone” (anonymous) links in SharePoint and OneDrive To find sites that created anonymous links in the last 28 days:
Start-SPODataAccessGovernanceInsight `
-ReportEntity SharingLinks_Anyone `
-Workload SharePoint `
-ReportType RecentActivity
To run the same report for OneDrive for Business accounts:
Start-SPODataAccessGovernanceInsight `
-ReportEntity SharingLinks_Anyone `
-Workload OneDriveForBusiness `
-ReportType RecentActivity
These commands generate sharing link activity reports that highlight sites (or OneDrive accounts) that created “Anyone” links in the last 28 days so they can be reviewed and cleaned up.
- Report on other sharing link types (optional) If needed, run similar reports for other link types to get a full picture of sharing:
- “People in your organization” links:
Start-SPODataAccessGovernanceInsight `
-ReportEntity SharingLinks_PeopleInYourOrg `
-Workload SharePoint `
-ReportType RecentActivity
- “Specific people” (guest) links:
Start-SPODataAccessGovernanceInsight `
-ReportEntity SharingLinks_Guests `
-Workload SharePoint `
-ReportType RecentActivity
(Use -Workload OneDriveForBusiness instead of SharePoint to target OneDrive.)
- Identify “Everyone except external users” (EEEU) sharing (optional) To find broadly shared content that may not be anonymous but is effectively public inside the organization, run:
- Sites shared with EEEU in last 28 days:
Start-SPODataAccessGovernanceInsight `
-ReportEntity EveryoneExceptExternalUsersAtSite `
-Workload SharePoint `
-ReportType RecentActivity `
-Name "PublicSiteViaEEEU"
- Items shared with EEEU in last 28 days (OneDrive):
Start-SPODataAccessGovernanceInsight `
-ReportEntity EveryoneExceptExternalUsersAtSite `
-Workload OneDriveForBusiness `
-ReportType RecentActivity `
-Name "PublicSiteViaEEEU"
- Clean up anonymous and broad sharing Once the reports are generated and downloaded (per your tenant’s configuration), use them to:
- Locate sites and items with “Anyone” links or EEEU permissions.
- Remove or downgrade those links (for example, replace “Anyone” links with “Specific people” or “People in your organization” links) using the SharePoint/OneDrive UI or additional PowerShell as appropriate.
- Optionally adjust tenant or site-level external sharing policies (for example, disallow “Anyone” links) using
Set-SPOTenantorSet-SPOSiteas needed, in line with organizational policy.
This approach provides a repeatable PowerShell-based method to discover anonymous sharing and then systematically reduce or remove it.
References: