Site icon Office 365 for IT Pros

How to Report the SharePoint URLs for Teams

Advertisements

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:

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.

Exit mobile version