How to Report the SharePoint URLs for Teams

Every Team has a SharePoint Site (Collection)

Updated: 15 February 2021

As you probably all know, Office 365 provisions every the group created for each team with a SharePoint site collection. Or rather site, because Microsoft seems to be moving away from referring to collections, possibly because the vast majority of collections created today come from Microsoft 365 Groups and Teams and therefore hold just one site.

In any case, a question posed by Syskit asked how to retrieve the associated SharePoint URLs for teams-enabled Microsoft 365 Groups. The article offered the suggestion that you could run the Get-UnifiedGroup cmdlet as follows:

Get-UnifiedGroup | Select DisplayName, SharePointSiteUrl

The big downside with this approach is that a) Get-UnifiedGroup is an “expensive” (slow) cmdlet and b) you return all Microsoft 365 Groups and not the ones enabled for Teams.

Using Get-Team to Find Teams

To be fair, the article was written in November 2018 and doesn’t reflect the state of the art ever since Microsoft delivered Version 0.9.5 of the Teams PowerShell module (the latest version is 1.1.16). The Get-Team cmdlet is the way to return the set of known teams in a tenant. Here’s what we can do:

$Teams = (Get-Team |Select GroupId, DisplayName, Alias)
ForEach ($T in $Teams) {
   $SPOURl = (Get-UnifiedGroup -Identity $T.GroupId | Select -ExpandProperty SharePointSiteURL)
   Write-Host "URL for the" $T.DisplayName "team is" $SPOURL "and the group mailbox alias is" $T.Alias "with email address" $T.PrimarySmtpAddress }

The code is simple. Create a set of teams and loop through the set to retrieve the SharePointSiteURL for each team. In fact, Get-UnifiedGroup returns three URLs for SharePoint:

  • SharePointSiteURL: The root of the site.
  • SharePointDocumentsURL: The URL for the default document library created in the site. Each channel in the team has a folder in this library, starting with General for the default channel.
  • SharePointNotebookURL: The URL for the shared OneNote notebook belonging to the Office 365 Group/team. Some organizations prefer to replace the Teams Wiki with OneNote.

Even Faster Code

Time moves on and we have better ways of reporting the information. As described in this article, here’s how we could do the job by using a single call to the Get-UnifiedGroup cmdlet.

$Groups = Get-UnifiedGroup -Filter {ResourceProvisioningOptions -eq "Team"} -ResultSize Unlimited | Select ExternalDirectoryObjectId, DisplayName, SharePointSiteURL, Alias, PrimarySmtpAddress
ForEach ($T in $Groups) {
  Write-Host "URL for the" $T.DisplayName "team is" $T.SharePointSiteURL "group mailbox alias is" $T.Alias "and email address" $T.PrimarySmtpAddress }

Why Not Use the New SharePoint Admin Center?

Some have suggested that you can use the new SharePoint Admin Center to find the URLs. Well, the Admin Center certainly displays the URLs, but it doesn’t distinguish between team sites that belong to Microsoft Teams (team-enabled) or those used by an Office 365 Group that isn’t team-enabled (an Outlook or Yammer group). Although you can certainly generate and download a CSV file from the Admin Center containing the site URL (along with other details) for all the active sites in the tenant, you still must isolate which sites belong to Teams and which don’t. Using the technique above starts with a list of Teams and doesn’t go near the non-team enabled sites.

The set of PowerShell modules used with Office 365 change all the time. That’s a good reason to keep up with change by subscribing to the Office 365 for IT Pros eBook. Chapter 13 tells all about how to manage Office 365 Groups and Teams with PowerShell.

8 Replies to “How to Report the SharePoint URLs for Teams”

  1. I try this but I receive this error…. “Unable to provision Resource” and is impossible retrive SharePoint url for several Teams. Do you have an idea?

    1. Could be due to some of the background processing restrictions Microsoft has put in place to ease the strain on the Office 365 infrastructure. It’s probably a transient error.

  2. Hello Tony,
    This is a great article, I have imported and installed the MicrosoftTeams module, but I still get The term ‘Get-UnifiedGroup’ is not recognized as the name of a cmdlet
    Do you have any suggestions?

Leave a Reply

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