Identify stale, unowned, and redundant SharePoint sites and produce an archive and cleanup plan.
Complexity: Intermediate. Impact: governance + storage-optimization + compliance + reporting.
Why use this workflow
SharePoint sprawl is a common governance problem in Microsoft 365 tenants. Over time, project sites outlive their projects, owners leave the company, and teams create near-duplicate sites because they cannot find the original. The result is storage growth, confused end users, stale content surfacing in search, and compliance risk from orphaned data.
This workflow scans every non-personal SharePoint site in the tenant and flags three classes of hygiene issues:
- Inactive sites: no modifications in the last 90 days (configurable).
- Ownerless sites: no user currently holds the Owner permission, which blocks self-service governance and membership changes.
- Likely duplicates: sites with identical or near-identical display names, an indicator of redundant workspaces.
The output is a CSV report with a recommended disposition (Archive, Review, or Reassign Owner) for each flagged site, which gives you the input for a governance review cycle.
Run this on a regular cadence, before storage-quota renewals, or ahead of a tenant-to-tenant migration.
Expected outcomes
After completing this workflow you will have:
- A full inventory of SharePoint sites in the tenant (excluding OneDrive personal sites).
- A CSV report (
SharePoint_Hygiene_Report.csv) listing every site with one or more issues, including URL, current owners, last-modified date, detected issues, and a recommended action. - Counts of total sites analyzed and total sites flagged, for reporting to stakeholders.
- A prioritized list of candidates to archive (inactive), reassign (ownerless), or consolidate (duplicates).
You can hand the report to a governance steering committee or the site business owners for disposition sign-off.
Risks and considerations
Important considerations
- Do not auto-delete based on this report.
lastModifiedDateTimeon a site can lag behind real user activity (for example, file views without edits). Require human sign-off before deletion. - Anonymized reporting. By default, Microsoft 365 admin reports conceal user and site names. If your hygiene data comes back with obfuscated names, clear the concealment setting under Settings > Org settings > Reports in the Microsoft 365 admin center, or PATCH
/admin/reportSettingsto setdisplayConcealedNames=false. - Legal hold and retention. Do not archive or delete sites under eDiscovery hold or a retention policy without consulting Compliance, even if they are flagged as inactive.
- Duplicate detection is heuristic. Name-based matching produces false positives (for example, "HR" as a common prefix). Treat duplicate flags as candidates for review, not confirmed redundancy.
- Ownership via permissions vs. group owners. Microsoft 365 group-connected sites derive owners from the backing group. The site permissions endpoint may show Owner roles differently than the group's owner list. Cross-reference both when a site is flagged ownerless.
- API throttling. Large tenants can hit Graph throttling. Implement exponential backoff on 429 responses.
Required permissions
| Permission | Why it's needed |
|---|---|
| Sites.Read.All | Enumerate all SharePoint sites and read their metadata |
| Sites.FullControl.All | Read site permissions to determine ownership |
| Reports.Read.All | Access SharePoint site usage and activity reports |
| ReportSettings.ReadWrite.All | Disable anonymized reporting so site names are visible in reports |
| Group.Read.All | Resolve owners for Microsoft 365 group-connected sites |
Ask Dex
Paste the prompt into a Dex conversation.
Prompt for IT admins
Analyze all SharePoint sites in our tenant for hygiene issues: flag sites that are inactive (no activity in the last {inactive_days} days), ownerless, or likely duplicates. Produce a CSV report with a recommended archive/reassign/consolidate action for each flagged site.
Manual steps (admin center)
The manual path combines the SharePoint admin center and the Microsoft 365 admin reports. It suits smaller tenants or spot-checking specific sites.
Step 1: Turn off anonymized reporting (once)
- Go to the Microsoft 365 admin center > Settings > Org settings > Services > Reports.
- Clear Display concealed user, group, and site names in all reports.
- Click Save.
Step 2: Pull the SharePoint site usage report
- Go to the Microsoft 365 admin center > Reports > Usage > SharePoint > Site usage.
- Set the date range to Last 90 days.
- Click Export to download the CSV.
- In the CSV, sort by
Last activity date. Rows older than 90 days (or with no activity) are inactivity candidates.
Step 3: Identify ownerless sites
- Go to the SharePoint admin center > Sites > Active sites.
- Add the Primary admin column through the column picker if it is not visible.
- Filter or sort on Primary admin. Sites with a blank value are ownerless.
- For group-connected sites, also verify in the Microsoft 365 admin center under Teams & groups > Active teams & groups that the backing group has at least one owner.
Step 4: Detect likely duplicates
- In the SharePoint admin center, go to Sites > Active sites and click Export.
- Open the export in Excel, select the Site name column, and use Conditional Formatting > Highlight Cells Rules > Duplicate Values.
- Review the highlighted rows. The same name across different URLs is a duplicate signal.
Step 5: Build the disposition plan
- Combine the three lists into one spreadsheet and add a Recommendation column:
Archive(inactive),Reassign Owner(ownerless), orReview for consolidation(duplicate). - Circulate the plan to site business owners for sign-off before acting.
Microsoft Graph API
The Graph approach is the most scalable and produces a repeatable, scriptable report. All endpoints are against https://graph.microsoft.com/v1.0.
1. (Optional) Turn off concealed names
PATCH /admin/reportSettings
Content-Type: application/json
{
"displayConcealedNames": false
}Expected response: 204 No Content.
2. Enumerate all sites
GET /sites?search=*&$select=id,displayName,webUrl,lastModifiedDateTimeFollow @odata.nextLink until exhausted. Filter out personal sites by skipping any webUrl containing -my.sharepoint.com.
3. Check ownership per site
GET /sites/{site-id}/permissionsIn the response, collect entries where roles includes "owner". If the filtered list is empty, flag the site Ownerless.
4. Pull the SharePoint site usage report (bulk activity)
GET /reports/getSharePointSiteUsageDetail(period='D90')Returns CSV with Last Activity Date per site. Join on Site Id against the list from step 2. Flag any site whose last activity is more than 90 days ago (or null) as Inactive.
5. Duplicate detection
Normalize displayName (lowercase, trim whitespace) and group sites by the normalized key. Flag groups with more than one member as Likely Duplicate.
6. Build the report
For each site with one or more flags, emit a record:
{
"SiteName": "Marketing Team",
"Url": "https://contoso.sharepoint.com/sites/marketing",
"Owners": "",
"LastModified": "2024-02-11T09:14:00Z",
"Issues": "Ownerless, Inactive (>90 days)",
"Recommendation": "Archive"
}Throttling
On a 429 Too Many Requests response, honor the Retry-After header and back off exponentially. For large tenants, batch the permission checks with the $batch endpoint (up to 20 requests per batch).
PowerShell
The approach uses the Microsoft.Graph PowerShell SDK to enumerate sites, check ownership, pull the usage report, detect duplicates, and export a CSV with recommendations.
Prerequisites
- Install the Graph SDK if you have not already:
Install-Module Microsoft.Graph -Scope CurrentUser - Connect with the required scopes:
Connect-MgGraph -Scopes "Sites.Read.All", "Sites.FullControl.All", "Reports.Read.All", "ReportSettings.ReadWrite.All" - (Optional) Turn off concealed names so the report contains real site names:
Update-MgAdminReportSetting -DisplayConcealedNames:$false
Approach
- Enumerate sites. Use
Get-MgSite -Search '*' -Allto pull every site in the tenant, then filter out OneDrive personal sites. - Check ownership. For each site, call
Get-MgSitePermissionand look for entries with theownerrole. - Activity check. Compare each site's
LastModifiedDateTimeagainst a configurable threshold (for example, 90 days). - Duplicate detection. Group sites by normalized (lowercased, trimmed) display name and flag any name that appears more than once.
- Recommendation logic. Inactive:
Archive. Ownerless only:Reassign Owner. Duplicate only:Review for consolidation. Multiple flags:Archive. - Export. Write
SharePoint_Hygiene_Report.csvto the output path.