Today, I wanted to get a full overview of all the Microsoft Teams teams sites that I have in my tenant. I decided to put PnP PowerShell to the test for this.
I found that Get-PnPTenantSite didn’t include my team sites and therefore I had to look for different options. Quite quickly I found a solution. I had to go through the following steps:
- Connect to my SharePoint Admin Center site.
- Get a list called: DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS
- Display the list items in this list
Connecting to the Admin Center site
Table of Contents
To connect to the Admin Center site I’m running the following command:
Connect-PnPOnline https:/ /mytenant-admin.sharepoint.com
Get the list
First I need to get the site. Then I load my lists just to have a look at which lists exist:
$site = Get-PnPSite
$web = $site.RootWeb
Now a quick look at $web.Lists shows me that there is a list with a very long name: DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS
Not sure who came up with this name for a list. But it is very noticeable.
Now I get my list:
$list = $web.Lists
Display The List Items
Ok, we are nearly there. Just get all the list items and spit out the SiteUrl
for ($x = 0; $x -lt $list.ItemCount; $x++ )
$item = $list.GetItemById($x)
Write-Host $item.FieldValues.SiteUrl : $item.FieldValues.TemplateTitle
Yes I know I could clean up the above code a bit. e.g. use a Query and query the list for the list items. But for simplicity I kept the code as simple as possible.
Ok, So now I’ve got all of my site collections listed with their templates used. All the sites marked Team site are my modern team sites.
So now we need to find a way to filter out the Modern Team sites that were created within SharePoint rather than Microsoft Teams. ( Thanks Paul Keijzers for pointing this out
!). Unfortunately there isn’t an option for this yet!