Report Group and Teams Enabled SharePoint Online Sites using Powershell

In this post, I am going to share powershell commands to find and export Group and Teams enabled SharePoint Online Sites. The output includes the field GroupEnabled (Groupify) which indicates the site is connected with group or not, and the result object also includes the field TeamEnabled (Teamify) which indicates whether the Teams feature enabled in the site’s associated group or not.

Before proceeding, install the Exchange Online Powershell V2 module and SPO Powershell module. Run the below commands to connect Exchange Online (EXO) and SharePoint Online modules:

$Cred = Get-Credential
#Connect Exchange Online Powershell module
Connect-ExchangeOnline -Credential $Cred
#Connect SharePoint Service
Connect-SPOService -Url "https://YourTenantName-admin.sharepoint.com " -Credential $Cred

Export all SPO Sites with Group and Team Details

Here, we are fetching site details using the Get-SPOSite command and retrieve Office 365 Group object with Get-UnifiedGroup command, the group object includes the property resourceProvisioningOptions which includes the array of values, we need to check whether this array includes the value “Team” to identify the teams feature is configured or not in the group.

$Result = @()
$AllSites = Get-SPOSite -IncludePersonalSite:$False -Limit All | Select Title,URL
$TotalSites = $AllSites.Count
$i = 1 
ForEach ($Site in $AllSites) {
Write-Progress -Activity "Processing $($Site.Title)" -Status "$i out of $TotalSites completed"
$O365Group = $null;
$TeamEnabled = $false;
#Once again call Get-SPOSite for each site with -Detailed switch to get GroupId property
#The bulk enumeration command (Get-SPOSite -Limit All) do not support -Detailed switch
$GroupId = (Get-SPOSite $Site.URL -Detailed).GroupId.Guid
if($GroupId -ne $null) {
$O365Group = (Get-UnifiedGroup -Identity $GroupId -ErrorAction SilentlyContinue)
if($O365Group -ne $null -and $O365Group.resourceProvisioningOptions -contains "Team") {
$TeamEnabled = $true;
}
}
$Result += New-Object PSObject -property @{ 
SiteName = $Site.Title
SiteURL  = $Site.URL
GroupEnabled = if ($O365Group -ne $null) { $true } else { $false }
GroupName  = if ($O365Group -ne $null) { $O365Group.DisplayName } else { $null }
GroupID  = if ($O365Group -ne $null) { $GroupId } else { $null }
GroupMail  = if ($O365Group -ne $null) { $O365Group.PrimarySmtpAddress } else { $null } 
GroupOwner  = if ($O365Group -ne $null) { $O365Group.ManagedBy -Join "," } else { $null } 
TeamEnabled  = $TeamEnabled   
}
$i++
}
$Result | Select SiteName,SiteURL,GroupEnabled,GroupName,GroupID,GroupMail,GroupOwner,TeamEnabled |
Export-CSV "C:\AllSPOSites.CSV" -NoTypeInformation -Encoding UTF8

The above commands store the details in the array object $Result, we can generate the required report from this result array.

List all sites without group feature

You can just filter the $Result array with Where-Object to list sites without a group.

$Result | Where-Object { $_.GroupEnabled -eq $false } | Select SiteName,SiteURL

Alternatively, you can list sites only that are connected with a group.

$Result | Where-Object { $_.GroupEnabled -eq $true } | Select SiteName,SiteURL,GroupName,GroupOwner

Get all sites without group and teams feature

$Result | Where-Object { $_.GroupEnabled -eq $false -and $_.TeamEnabled -eq $false} | Select SiteName,SiteURL

Alternatively, you can list sites with group, but without teams feature.

$Result | Where-Object { $_.GroupEnabled -eq $true -and $_.TeamEnabled -eq $false} | Select SiteName,SiteURL,GroupName

Get all sites with group and teams feature

$Result | Where-Object { $_.GroupEnabled -eq $true -and $_.TeamEnabled -eq $true} | Select SiteName,SiteURL,GroupName

Sample CSV Report

Find Group and Teams Enabled SharePoint Online Sites using Powershell

Advertisement

11 thoughts on “Report Group and Teams Enabled SharePoint Online Sites using Powershell”

  1. Hello, I am getting error as get Get-UnifiedGroup cmdlet can not be recognized. Also access denied when trying to connect. I have given organization management access already

    Reply
    • You can replace the following commands for getting sites information. The field LastContentModifiedDate provides the last activity that happened on the site.

      $AllSites = Get-SPOSite -IncludePersonalSite:$False -Limit All | Select Title,URL, LastContentModifiedDate,HubSiteId

      Inside the AllSites loop, you can find hub site information if the site is associated with a hub site.

      $HubSite=$null
      If($Site.HubSiteId -ne [System.Guid]::empty)
      {
      $HubSite = (Get-SPOHubSite -Identity $Site.HubSiteId -ErrorAction SilentlyContinue)
      }

      Then get hub name: $HubSite.Title

      To retrieve sub-sites, you can use PnP PowerShell.

      Connect-PnPOnline -Url $Site.URL

      #Get subsites
      $SubWebs = Get-PnPSubWebs -Recurse

      Reply

Leave a Comment