Groupify and Teamifiy a SharePoint Online Site using Powershell

In this post, I am going to explain how to programmatically connect an existing SharePoint Online site with Office 365 Group and add Teams feature using Powershell (and Office 365 CLI). We can use the SPO Powershell command Set-SPOSiteOffice365Group to integrate a site with a new Office 365 group and use New-Team command to create a team from the site connected Office 365 group.

Before proceeding, install SPO and Teams Powershell Modules and run the below commands :

$Cred = Get-Credential
#Connect Teams module
Connect-MicrosoftTeams -Credential $Cred
#Connect SharePoint Service
Connect-SPOService -Url "https://YourTenantName-admin.sharepoint.com " -Credential $Cred

Groupify a SharePoint Online Site

Run the following command to connect the root site collection with a new group.

#Groupify - Connect the site to new O365 Group
$SiteURL = "https://YourTenantName.sharepoint.com/sites/TestSite1"
$GroupName = "TestGroup"
$MailNickName = "TestGroup"
Set-SPOSiteOffice365Group -Site $SiteURL -DisplayName $GroupName -Alias $MailNickName

Teamify the group which is connected with the site

Once the site is integrated with a modern group, we can get the id (GroupId) of the connected group from spo_site object and create a new team from this new group.

#Teamify - Add Teams feature in the site associated O365 Group
$SiteObj = Get-SPOSite -Identity $SiteURL
New-Team -GroupId $SiteObj.GroupId.Guid

Office 365 CLI : If you are a big fan of Office 365 CLI, you can refer this post to achieve this functionality using Office 365 CLI.


Advertisement

Leave a Comment