ROT (Redundant, Obsolete, Trivial) content can be the downfall of content discoverability and security in most organizations. As a content administrator, you need to ensure that unused documents and other pieces of information are continuously reviewed for relevance and then archived or deleted if necessary.
This article covers the methods available to identify inactive SharePoint sites and take appropriate action.
Requirements
Roles & Licensing
• SharePoint Admin – To view and archive sites.
• M365 Business or Enterprise License – Any Microsoft Business or Enterprise license that includes SharePoint P1 or P2.
• SharePoint Advanced Management – Necessary if the SAM Inactive Sites Policy method is used.
Apps & Modules – Update setting via PowerShell
• PowerShell – There are several versions and ways to access PowerShell, in our guide we will use PowerShell ISE.
• PnP PowerShell module – This module is used to export a unused SharePoint sites report and delete sites and requires SharePoint Admin to run.
Method 1 – SharePoint admin center
Generate the report
To use the SharePoint admin center to generate a report of the least active sites in your tenant, navigate to ‘Active Sites’, change the view to ‘Least active sites’ and then export the csv.

You will receive a report like the example below:

Clean up unused sites
Once you have identified the sites you would like to clean up and have confirmed with owners that they are not needed anymore, use the standard UI to simply delete the sites (or archive them if you have Microsoft 365 Archive configured on your tenant).

Advantages
- Always available – By using the filters available in the normal SharePoint admin center, this report is always available and up to date.
- No code – No code or scripts are required to perform the cleanup.
Disadvantages
- Manual – This is a manual process, and it takes time to determine which sites meet the ‘unused’ criteria.
- False positives – Some sites in SharePoint may be used as read-only resources resulting in them appearing as ‘unused’ when employees may be actively visiting and consuming information from them.
- No delegation – Once you have determined a site is ‘unused’, you will need to follow up with the site owner(s) to find out if this is expected or if they still need the site.
- No bulk actions – Without the ability to action items in bulk, this process becomes very time consuming for the admins and users involved.
Method 2 – PowerShell
Generate the report
To generate a report of inactive sites, you will need to connect to PnP Online via PowerShell. Ensure that you have the correct admin roles and the App Registration details to allow you to authenticate to your SharePoint instance.
Below is an example that will fetch inactive sites on ‘X’ date:
#Get all non-OneDrive sites
$SiteCollections = Get-PnPTenantSite -Filter "Url -like <Tenant URL> -and Url -notlike '-my.sharepoint.com/'"
#Get all 'Inactive' site collections
$SiteCollections | Where {$_.LastContentModifiedDate -le <Date>} | Select Title, Url, LastContentModifiedDate, -LockState, Owner, IsHubSite,StorageMaximumLevel
To export a report, you can run the Export unused SharePoint sites.ps1 script once you have updated the required variables:
- TenantAdminURL – The SharePoint Admin center URL for your tenant that is used when connecting to your SharePoint instance.
- TenantURL – The root URL of you SharePoint site. This is used when fetching the inactive sites.
- ClientID – The app registration ID used with connecting to your SharePoint instance.
- DaysInactive – How many days since the last activity do you consider a site to be inactive. By default, this is set to 90 days.
- CSVPath – Where you would like the inactive site csv report to be saved to.
Clean up the unused sites
To clean up (delete) an unused site, you can use the following command:
Remove-PnPTenantSite -Url <siteURL>
This will place the site into the SharePoint admin center recycle bin for 90 days before permanent deletion.
To perform deletion in bulk, you can use the Delete Unused SharePoint Sites.ps1 script to action the items in the csv report.
Advantages
- Detailed Reports – You can use the scripts to pull more detailed reports than those directly from the SharePoint admin center.
- Bulk Actions – Once the inactive sites report has been reviewed, sites can be deleted in bulk.
Disadvantages
- Manual – Reports need to be run and actioned manually by a SharePoint Admin.
- False positives – Some sites in SharePoint may be used as read-only resources resulting in them appearing as ‘unused’ when employees may be actively visiting and consuming information from them.
- No delegation – Once you have determined a site is ‘unused’, you will need to follow up with the site owner(s) to find out if this is expected or if they still need the site.
Method 3 – SharePoint Advanced Management – Inactive sites policy
If you have the additional licensing for SharePoint Advanced Management (SAM) directly through a SAM license or through Microsoft 365 Copilot, you can set up an inactive sites policy to find any sites within your environment that are no longer being used.

For more information on how to do this, follow the Microsoft documentation on how to Create an inactive site policy.
Advantages
- Easy to configure – Policies are quick to configure.
- Reduced admin responsibility – With workspace owners being given the option delete inactive sites, there is less manual intervention.
- Automated Archiving – If owners don’t action their inactive sites, they can automatically be archived or set to read only.
Disadvantages
- Additional licensing – SAM capabilities require additional licensing.
Method 4 – SProbot
SProbot’s Inactive site cleanup tool makes it extremely easy to clear unused SharePoint sites from your tenant. It creates tasks for group/site owners to review and action, and then automatically archives a site/group if there is no response.
Step 1 - Enable and configure cleanup
Open the Inactives cleanup tool under Workspace management > Cleanup > Inactives
Note: You need to have Microsoft 365 Archive set up on your tenant for this tool to show as available.

Select to enable automatic cleanup, and choose:
- The number of days before a SharePoint site is seen as inactive (sites are seen as active if they’re being viewed, not just if their contents are updated).
- The frequency and number of reminders to send group/site owners before a site is archived.

Step 2 – Review and action cleanup tasks
When a site reaches the defined inactivity threshold, a cleanup task is created for all group/site owners. These tasks display under the My items tab for each owner in the bundled Workspaces app in Teams.

They can then decide to either renew – for another 90, 180 or 365 days depending on your configuration - or immediately archive or delete the Microsoft 365 group (or site only, if it’s not group connected).

You can also, as an admin, review workspaces across all users and choose to directly action them if you wish.

Advantages
- No code – No code or scripts are required to perform the cleanup.
- Only a few clicks – SProbot gets to work immediately finding any inactive sites within your environment.
- Reduced admin responsibility – With workspace owners being given the option to renew, archive or delete inactive sites, there is less manual intervention.
- Automated Archiving – If owners don’t action their inactive sites, they are automatically archived.