Why Site Renames and Teams Private Channels Mean You Should Review the Usage of Get-SPOSite

Redirect Sites

One of the actions taken when the URL for a SharePoint Online site is renamed is the creation of a redirect site. A redirect site takes the old site URL and uses special headers and logic to redirect browser requests to the new URL for the site. Essentially, the redirect site is a pointer for the old site to make sure that links to the old site URL continue to work.

The documentation explains that redirect sites are created with a special template (REDIRECTSITE#0). This means that you can use the Get-SPOSite PowerShell cmdlet to see a list of redirect sites with the command:

# Find all redirect sites in the tenant
Get-SPOSite -Template "REDIRECTSITE#0"                                               
Url                                                                    Owner Storage Quota
---                                                                    ----- -------------
https://office365itpros.sharepoint.com/sites/europeanoffice365engage            26214400
https://office365itpros.sharepoint.com/sites/askhr                              26214400
https://office365itpros.sharepoint.com/sites/EngineeringExcellence              26214400

If you look at the details of a redirect site, you’ll see that its Lockstate is set to ReadOnly and its Title is RedirectSite. There’s no obvious link to the new (renamed) site URL.

Being More Precise with Get-SPOSite

Many PowerShell scripts create a collection of sites for processing by running a command like:

# Form collection of SharePoint Online sites in a tenant 
$Sites = Get-SPOSite -Limit All

The collection created will contain redirect sites because you haven’t told Get-SPOSite to exclude them. It might be the case that the presence of the redirect sites won’t cause any problems for the other commands in the script, but it’s probably best to exclude these sites unless you have good reason to process them. Accordingly, the call to Get-SPOSite should be updated. For instance, you could simply filter out the redirect sites:

# Get SharePoint Online sites without redirect sites
$Sites = Get-SpoSite -Limit All |?{$_.Template -ne "REDIRECTSITE#0"}  

Teams Private Channel Sites Add to the Mix

The output now excludes redirect sites but includes hub sites, app catalogs, and the sites owned by Teams private channels (which use a template called TEAMCHANNEL#0). In most cases, it’s best not to fetch all sites and instead ask Get-SPOSite to only fetch the sites you want to process. For instance, you might only want team sites (those connected to Office 365 Groups with or without Teams), in which case we’d use the command:

# Get SharePoint Online sites connected to Office 365 Groups
$Sites = Get-SpoSite -Limit All -Template "GROUP#0"  

The popularity of the site URL rename feature and the availability of Teams private channels will lead to a lot more types of sites in use. These features are part of the reason why SharePoint Online now supports two million sites per tenant). With that in mind, it’s a good idea to be a lot more precise about how the Get-SPOSite cmdlet is used in scripts.


Worrying about the detail is something we do all the time. It’s this kind of thing that makes the Office 365 for IT Pros eBook invaluable for tenant administrators. Or anyone else with an interest in how Office 365 really works.

2 Replies to “Why Site Renames and Teams Private Channels Mean You Should Review the Usage of Get-SPOSite”

  1. Have you done any testing to evaluate what will happen if a SPO site that is connected to a Team is renamed? I’m assuming that this will break the channels in Teams but hopefully I’m wrong and MS has put some checks in place to keep that from happening.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.