Microsoft 365 security

Retrieve associated SharePoint site URL for Microsoft Teams

Find out how to retrieve the associated SharePoint Site URL for Microsoft Teams by reading this guide from our dev lead.

Recently we needed to retrieve a list of SharePoint site collections associated with our Microsoft Teams.
This proved more difficult than we anticipated and could not find a straightforward solution. So in case somebody else stumbles upon this problem here are some things that we tried out.

Not saying there isn’t a better way of doing this or there won’t be anything in the future, but the options outlined here work in a more or less acceptable fashion.

Option No. 1 – Microsoft Graph API

Use the Microsoft Graph API.

You can get the list of all Office 365 groups by using the following request:$filter=grouptypes/any(i:i eq 'Unified')

Once the list is retrieved there is a resourceProvisioningOptions field which will have a ‘Team’ value if it is a Microsoft Team. Unfortunately, you cannot filter by resourceProvisioningOptions directly using the $filter query parameter.

Now that you have the Teams you can iterate through all the Team IDs and use the following request to retrieve the SharePoint URL:{TeamId}/sites/root/weburl

But there is a catch if the Team is private the request above will probably return with a 403 status code.

Option No. 2 – Exchange Online Powershell

Use Exchange Online Powershell:

Once the session is imported you can simply use:

Get-UnifiedGroup | select DisplayName, SharePointSiteUrl

This solution is good because unlike the graph API this will also return SharePoint URLs for private Office 365 Groups (Teams). You will need to determine which Office 365 Group is actually a team by other means.

Option No. 3 – SharePoint admin center

The Office 365 Group (which by definition also includes Teams) site collections show up in the new SharePoint admin center. To get the URLs programmatically you can read the DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS SharePoint list located on the admin site.

This is the list used as the data source for the site collections list when you look at the network traffic. There are multiple interesting fields in this list including IsGroupConnected, GroupId, SiteUrl, SiteId.

The list is also accessible on the web by using the direct URL:


By reading this list directly using CSOM you can retrieve the Group SharePoint Site URLs easily.

Or you can use the SharePoint REST api:

https://{yourTenant}'DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS')/items?$filter=IsGroupConnected eq 1&$select=Title,GroupId,SiteUrl,SiteId

With this option, you will also still need to determine which Office 365 Groups are actually a team by other means ie. with the graph API as mentioned in Option 1. Of course, if you have the Team object ID then you can simply compare with the GroupId field.

If you by any chance find a more elegant solution, please notify us.

Syskit Point – Your Office 365 and SharePoint ally

Control the security of your Office 365 and SharePoint environment with Syskit Point:

  • List all Microsoft Teams and their associated site collections and Office 365 Groups in a tenant
  • Grant, transfer, and copy SharePoint permissions in bulk
  • List all permissions by a single user or SharePoint group
  • Control the external access to your sites, Microsoft Teams, and OneDrive accounts

Subscribe to our Newsletter

Related Posts