SharePoint and Teams

How to clean up orphaned SharePoint sites and teams

Learn how to remove or reassign SharePoint sites and teams without active owners to safeguard at-risk data or free up storage on your tenant.
Scott Ortlepp
Updated
July 3, 2024
4 min to read

If your organization is very large or dynamic in nature with people joining and leaving at short intervals, it can be fairly easy for teams and SharePoint sites to become orphaned regularly. Even if this is not the case, content does still become orphaned over time.

How to determine when a team is orphaned

A team is orphaned when there are no owners assigned to it. Technically, this means the connected Microsoft 365 group does not have any owners.

How to determine when a SharePoint site is orphaned

Defining a SharePoint site as orphaned is more complex because SharePoint sites can be either group-connected or not.

1 – SharePoint sites without groups

SharePoint sites without groups are any sites that do not have a M365 group (Microsoft 365 group) connected to them, for example communication sites.

These sites are considered to be orphaned when there are no users assigned to the ‘Site Owners’ group within the site(this group is a SharePoint group and exists only within the site).

2 - Group-connected sites

Group-connected sites are, as the name suggests, connected to a Microsoft 365 group. These will always be team sites and are the default type when creating a new site from the SharePoint start page. There are three scenarios when a group-connected site can be considered orphaned:

1.      No group owners – when there are no users assigned to the ‘Owner’ role of the connected Microsoft 365 group.

2.      No site owners – when there are no users assigned to the ‘Site Owners’ group (like with sites without groups).

3.      No group or site owners– when there are no users assigned to either the ‘Site Owners’ group or to the connected Microsoft 365 group.

Cleanup method 1 –Admin centers

This method uses the standard Teams, SharePoint or Exchange admin centers and does not require any scripting or code knowledge.

Find and delete orphaned teams using the Teams admin center

Before you begin, confirm that you have the Teams administrator role.

  1. From the Teams admin center, navigate to ‘Manage teams’ below the ‘Teams’ tab on the left navigation.
  2. Scroll through the teams on your tenant until you find a team with an orange exclamation mark ⚠️ in the ‘Owners’ column.

From here, you will be able to either assign an owner to delete the orphaned team.

If you have hundreds of teams, this is not a very effective method of managing your orphaned teams and it doesn’t cover Microsoft 365 groups (M365 groups) that aren’t teams connected.

Find orphaned sites using the SharePoint admin center

This method doesn’t enable you to easily determine (at least not at a glance) which sites are orphaned, it only enables you to individually review each site’s membership.  

Before you begin, confirm that you have the SharePoint administrator role.

  1. From the SharePoint admin center, navigate to ‘Active sites’ below the ‘Sites’ tab on the left navigation.
  2. Select the site you believe has become orphaned.
  3. In the fly-out panel, select the ‘Membership’ tab.
  4. If there are no users assigned in the ‘Owners’ section of the ‘Membership’ tab, the site is orphaned.
  5. Assign an owner or delete the site.

*Note: this only works with group-connected sites.

Find orphaned groups using the Exchange admin center

Before you begin, confirm that you have the Exchange administrator role.

  1. From the Exchange admin center, navigate to ‘Groups’ below the ‘Recipients’ tab on the left navigation.
  2. Apply the ‘Ownerless groups’ filter to display all orphaned M365 group workspaces.

*Note: The same filter is available from the Microsoft 365 admin center on the ‘Active teams & groups’ tab.

Cleanup method 2 – PowerShell

Managing ownerless M365 groups

Before you run one of the following commandlets, you will need to ensure that you have the Exchange administrator role and have the Exchange Online Management module installed, authorized and connected.

Report on orphaned groups

To find orphaned M365 groups within your tenant use the following commandlet:

Get-UnifiedGroup | Where-Object {-Not $_.ManagedBy}

If you want to export a report, use the following script: Report on Orphaned Groups

Add new owners to groups

To add a new owner to a group, you can use the following commandlets:

Add-UnifiedGroupLinks -Identity <M365 Group Primary SMPT Address> -LinkType "Members" -Links <User UPN>
Add-UnifiedGroupLinks -Identity <M365 Group Primary SMPT Address> -LinkType "Owners" -Links <User UPN>

To bulk add new owners to groups, use the following script: New Orphaned Group Owner

Delete orphaned groups

To delete a group, use the following commandlet:

Remove-UnifiedGroup -Identity <M365 Group Primary SMPT Address> -confirm:$False

To bulk delete groups, use the following script: Delete Orphaned Groups

Managing ownerless SharePoint sites

Before you run this script, you will need to ensure that you have the SharePoint administrator role, have the SharePoint Online Management module installed and authorized.

Depending on the type of SharePoint site you create, it will not always be M365 group connected, classic team sites and communication sites are the most common. To find the orphaned non-group-connected sites in your tenant, you can use the following PowerShell script: Report on Orphaned Sites

Cleanup method 3 – Third-party tool

SProbot’s orphan cleanup tool includes the ability to list both SharePoint sites and teams in a single report, and then either assign ownership or delete workspaces individually or in bulk.

Conclusion

Minimizing the number of orphaned SharePoint sites and teams can be a time consuming and often overlooked part of tenant maintenance. There are however significant upsides to preventing data loss and freeing up much needed storage availability.

Need an easy way to clean up orphaned sites?
Use SProbot's tenant cleanup tools to find and then assign ownership or delete orphans
Get useful SharePoint and Teams insights first

See how SProbot can help you keep your M365 tenant tidy

We'll show you how to tame content sprawl and make it easier for your users to find what they need

Get a demo