Find All Office 365 Group Sites in SharePoint Online

Requirement: Get All Group Sites in SharePoint Online.

How to Find All Group-Connected Team Sites in SharePoint Online?

The new SharePoint Online admin center lists all group sites and modern sites. You can log in to SharePoint Online Admin Center >> Click on “Active Sites” and then look for the “Primary Admin” Column, which has “Group Admin” to get the list of all SharePoint Online Group site collections.

find all group sites in sharepoint online

In addition, we have a “Microsoft 365 Group” column to identify Group sites!

sharepoint online find all microsoft 365 group sites

SharePoint Online: List Group Sites using PowerShell

We can filter site collections based on its template to get Microsoft 365 Group-enabled sites. Run these lines of PowerShell script in SharePoint Online Management Shell.

#Set Admin Center URL
$AdminCenterURL = "https://crescent-admin.sharepoint.com/"

#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)

#Get All Group Sites
Get-SPOSite | Where { $_.Template -like 'GROUP*'} | Select URL

This gets you the list of all group sites!

Get All Group Sites in SharePoint Online and Export to CSV:

Let’s get a list of group sites and export the data to a CSV file from the SharePoint side.

#Set Admin Center URL
$AdminCenterURL = "https://crescent-admin.sharepoint.com/"
$ReportOutput="C:\Temp\GroupSites.csv"

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)

#Get All Group Sites
$GroupSites = Get-SPOSite -Limit All -Template 'GROUP#0' -IncludePersonalSite:$False
Write-host "Total Number of Group Sites Found:"$GroupSites.count

$SiteData = @()
#Loop throgh each site
ForEach($Site in $GroupSites)
{
    #Get Group Site Data
    $SiteData += New-Object PSObject -Property @{
                'Site Title' = $Site.Title
                'URL' = $Site.Url
                'Last Modified' = $Site.LastContentModifiedDate
                'StorageUsed' = $Site.StorageUsageCurrent              
                }
}
#Export the data to CSV
$SiteData | Export-Csv $ReportOutput -NoTypeInformation
Write-Host -f Green "Group Sites Data Exported to CSV!"

And the script output report:

sharepoint online list group sites

How to Get the Office 365 Group of a SharePoint Site?

We can also get all SharePoint sites of Microsoft 365 groups from Exchange Online:

$SiteURL = "https://Crescent.sharepoint.com/sites/Legal"

#Connect to Exchange Online
Connect-ExchangeOnline -ShowBanner:$False

#Find the Office 365 group using the SharePoint site URL
$Group = Get-UnifiedGroup -ResultSize Unlimited | Where { $_.SharePointSiteUrl -eq $SiteURL}
Write-host $Group.Guid

#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

Get Group Sites using Exchange Online PowerShell

Let’s get all Office 365 groups and associated sites using Exchange Online PowerShell.

#Get Credentials to connect
$Credential = Get-Credential
 
#Connect to Exchange Online
Connect-ExchangeOnline -Credential $Credential -ShowBanner:$False

#Get All Office 365 Groups
$Groups = Get-UnifiedGroup -ResultSize Unlimited -SortBy Name
        $GroupSites = @()
        $Groups | Foreach-Object {
            $Group = $_
            $SiteURL = $Group.SharePointSiteUrl
            If($SiteURL -ne $null){
                $GroupSites += New-Object -TypeName PSObject -Property @{
                      GroupName = $Group.Alias
                      GroupUrl = $SiteURL
                      EmailAddress = $Group.EmailAddress
                      DisplayName = $Group.DisplayName
                      Privacy = $Group.AccessType
                      Owners = $Group.ManagedBy
                      Created = $Group.WhenCreated
                      Changed = $Group.WhenChanged
                }
            }
        }
        $GroupSites

#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *