create new teams from existing sharepoint online sites using powershell

Well, ok there is a really simple solution to this issue. The issue is that you have an existing SPO site BUT no Teams team associated (or created for it). The SPO site has to be a team site and it has to be a “modern” team site NOT a “modern” communication site. Have a look here for an explanation.

You can use the guide that Microsoft provides here – Create a Microsoft Team from SharePoint. That’s way to easy! How about adding it though using the gift of PowerShell?

Ok that’s sorta easy to do. If you are starting on a new machine, and from scratch (i.e. you don’t have any O365 PowerShell there), you can go here and do this:

  1. Install Teams PowerShell – Install Microsoft Teams PowerShell Module.
  2. Install SharePoint Online Management Shell (ok slightly more involved… Teams is much better 🙂 ) – Get started with SharePoint Online Management Shell.

That installs the PowerShell that you need to run the cmdlets to create a Team that will be attached to an existing SPO team site.

So have a look here…

This is an active site, that is called “This is a nonTeams Connected SharePoint Site” – I know I know, its not a clearly described site.

I want to create a Teams team that is attached to this existing SPO site.

The SPO site URL (the URL to the SPO site) is copy and pasted from the internet browser, and then the SPO admin URL on O365 is also copy and pasted. These are the values I would like to use in the variables part of the PowerShell script.

Ok now is the PowerShell part… this is the script that I would like to run:

## Create the variables that we want to use (only create it once :) )
$sPOSiteURL="https://yourtenant.sharepoint.com/sites/ThisisanonTeamsConnectedSharePointTeamsonly"
$sPOAdminURL="https://yourtenant-admin.sharepoint.com" 
## Pop up the login dialog for the username and password for the subsequent commands. 
$cred = Get-Credential  
## Connect to Teams using my admin creds  
Connect-MicrosoftTeams -Credential $cred  
## Now Connect to SPO using my admin creds  
Connect-SPOService -Url $sPOAdminURL -Credential $cred  
## Create an PS object for the SPO site that we want to create a new Team
$sPOTargetSite = Get-SPOSite -Identity $sPOSiteURL  
## Create a new Team associated with the existing SPO site
New-Team -GroupId $sPOTargetSite.GroupId.Guid 

I did run the script, all the way up to the last “New-Team” statement, and then just typed out $sPOTargetSite.GroupId.Guid into the PS window to see if a GUID is returned (and it was).

Then I ran the New-Team PS and got this back on my PS console:

The results from the PowerShell new Team creation attached to an existing SPO site

And so it worked 🙂

So, this is the view before running the PowerShell script:

Nothing, nada…

And this is the result after:

So that’s that… OR is it?

I’ll do the same with MS Graph API and post those results, but I have a particular need to fix (mysterious eh?), and I will find out if I can fix this later and post the problems / results.

Stay tuned!

Leave a Reply

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