Skip to content
Menu
SharePoint Gems
  • Power Platform
  • Development
    • SharePoint 2013
  • Migration
  • Administration
  • SP Online
  • Contact
  • About
    • Privacy Policy
SharePoint Gems

PowerShell to create Team Site in SharePoint Online

Posted on March 8, 2020September 29, 2021
PowerShell to create Team site in SharePoint Online
Image: PowerShell to create Team Site in SharePoint Online

Hello SharePointers,

In today’s article, we will learn about How to create a Team Site in SharePoint Online with PowerShell. This is the second part of the article series about creating SharePoint sites. In the last part, we learned about how to create a communication site in SharePoint Online using PowerShell. If you newly joined this blog and want to learn about the creation of the Communication site in SharePoint Online, then please click on how to Create a Communication site in Share Point Online.

Okay, That’s enough about the background. Let us move on to our current topic about How to create a TEAM site in SharePoint Online using PowerShell.

Contents hide
1 Requirement:
2 What is the TEAM site in SharePoint?
2.1 Types of Team site in SharePoint.
2.1.1 Classic Team Sites:
2.1.2 Modern Team Site:
3 Create a Team site in SharePoint Online.
4 Create SharePoint Online Team site using PowerShell.
4.1 Using SharePoint Online Management Shell (SPO Service) [creates Classic Team Site]
5 Create Modern Team Site Using PnP PowerShell
5.1 Full Line of code goes here.
5.2 Share this:
5.3 Like this:
5.4 Related

Requirement:

Create a Modern/Classic Team site in SharePoint Online using PowerShell.

What is the TEAM site in SharePoint?

As per Microsoft, A SharePoint Team site Connects you and your team to the content, information, and apps you rely on every day. For Example, A team site can be used to store and collaborate on files or to create and manage lists of information.

Types of Team site in SharePoint.

In SharePoint Online there are two types on Team site, and they are as below.

  1. Classic Team Site
  2. Modern Team Site

Classic Team Sites:

Classic Team sites are the team sites which are created based on STS#0 Template. This sites are NOT associated with Office 365 Groups. These type of sites have a User Interface same like as SharePoint 2013 sites. Please see image below.

PowerShell to create Team site in SharePoint Online
Img: Classic Team site

Modern Team Site:

Modern Team sites are the Team sites which are associated with Office 365 Groups. The Modern Team sites are created with “GROUP#0” Template of SharePoint Online. The Modern Team sites have a modern pages user interface. Please see image below.

PowerShell to create Team site in SharePoint Online
Image: team site in SharePoint Online

So Now we will see How to create Team Site n SharePoint online.

Create a Team site in SharePoint Online.

Please follow the below steps to create a new communication site in SharePoint Online.

  • Login to New SharePoint Admin center as tenant administrator or SharePoint Online Administrator.
  • Click on “Sites” >> “Active Sites” from the left navigation >> Click on “Create” from available options >> select “Communication site” to create a new communication site.
  • Fill the site properties like “site name” which will automatically become a URL of the site. The team sites are created under the /sites/ managed path by default, but you can change it to /Teams / if required.
  • If you notice in below screen, the feild “Group Email Address” is nothing but a Office 365 group mailbox id, Which is automatically taken as per the site name. This means SharePoint will automatically create an Office 365 group as per the site name.
  • Give the Site Description if required.
  • Set Privacy Settings and Site Language.
  • Team site in SharePoint Online PowerShell
    Create SharePoint Team Site

    Click on Next  and this will create your Modern Team site associated with Office 365 Group.

  • Here We go, Let’s see how our site looks.

    PowerShell to create Team Site
    Final “SharePointGems” Team Site

  • Ok, That’s, enough about the Manual Process and Let’s create Team site Using PnP PowerShell.

Create SharePoint Online Team site using PowerShell.

We can create Team site in Two ways, Using SharePoint Online Management Shell, and Patterns & Practices for PowerShell That means PnP PowerShell.

Using SharePoint Online Management Shell (SPO Service) [creates Classic Team Site]
#Declare Parameters
$AdminCenterUrl = "https://spforfun-admin.sharepoint.com"
$SiteUrl = "https://Spforfun.sharepoint.com/sites/ShareP  ointgems"
$SiteTitle = "SharePoint Gems"
$siteOwner = "sarang@spforfun.com"

#Connect SharePoint Online
Connect-SPOService -Url $AdminCenterUrl -credentials (Get-Credential)

#Poershell to create new communication site
New-SPOSite -Url $SiteUrl -Owner $SiteOwner -Template "STS#3"  -Title $SiteTitle -StorageQuota 1048

    The above block of code will a Classic Team site in the SharePoint Online Platform.

Now let us move ahead and create a Team site Using PnP PowerShell.

    Create Modern Team Site Using PnP PowerShell

Below the Single line of code will do our work, which means it will create a Modern Team site associated with Office 365 Group.

  New-PnPSite -Type "Team Site" -Title "SharePoint Gems" -Alias "sharepointgems"

This will create a new Modern Team site with Title “SharePoint Gems” and the URL                             ‘https://tenant.sharePoint.com/sites/sharepointgems’ OR ‘https://tenant.sharePoint.com/teams/sharepointgems’ based on the managed path configuration in the SharePoint Online Admin Portal.

    Full Line of code goes here.
#Declare all variables
$AdminCenterUrl = "https://spforfun-admin.sharepoint.com"
$SiteUrl = "https://Spfordun.sharepoint.com/teams/SharePointgems"
$SiteTitle = "SharePoint Gems"
$siteAlias = "SharePointGems"

#Get Credentials to connecct
$cred = Get-Credentials
Try
{
  #connect Admin site
  Connect-PnPOnline -Url $AdminCenterUrl -Credentials $Cred
  
  #Check if site exist
  $site = Get-PnpSite| Where {$_.Url -eq $SiteUrl}
  
  If ($Site -eq $null)
  {
    #SharePoint Online PnP Powershell to create communication site
    New-PnPSite -Type "Team Site" -Title $SiteTitle -Alias $siteAlias   
   write-Host "Site Collection $SiteUrl created Successfully!" -f Green
  }
  else
  {
    write-Host "Site $SiteUrl already Exist!" -f Yellow
  }
}
Catch
{
 wirte-Host "Error Occurred $($_.Exception.Message)" -f Red
}

You can create multiple team sites by creating a “.csv” file of multiple URL and reading in PnP Powershell.

If we want to create the same then we need to add foreach loop in the above code.

And That’s it. Bingo !!! we have successfully created a Team site using both the methods of PowerShell.

See more tutorials of SharePointgems

know more about new-pnpsite here.

Share this:

  • Print
  • Twitter
  • Facebook
  • LinkedIn
  • WhatsApp
  • Telegram
  • Pinterest
  • Reddit

Like this:

Like Loading...

Related

9 thoughts on “PowerShell to create Team Site in SharePoint Online”

  1. SharePointGems says:
    March 9, 2020 at 1:03 AM

    Guys Please send your feedback about this article here.

    Loading...
    Reply
  2. Igwe Chisom Henry says:
    March 11, 2020 at 6:53 PM

    Oh my God, Thanks i Just Found what i have been looking for in Months here. You are better

    Loading...
    Reply
  3. Pingback: How to Convert Site Page into News Post in SharePoint Online? - SPGems
  4. Pingback: SharePoint Online: Delete Folders using PnP PowerShell - SharePoint Gems
  5. SpAdam says:
    May 7, 2020 at 1:15 PM

    Another script-copy!

    Loading...
    Reply
  6. Dell Roszales says:
    May 21, 2020 at 8:13 AM

    Hello , i just want to share with you this money making method by using CPA ,learn more here >> https://warriorplus.com/o2/a/ps5v5/0

    Loading...
    Reply
  7. Serita Schomaker says:
    June 2, 2020 at 12:31 AM

    Hello , i see the your website get very good daily traffic , why donot you make more money by joining >> https://cutt.ly/ads-wordpress , your daily earning will be increased alongside with adsence try it now for few days and see your daily earning >> https://cutt.ly/ads-wordpress

    Loading...
    Reply
  8. Pingback: Retrieve all Communication Sites using PnP PowerShell - SharePoint Gem
  9. Agatha Lanson says:
    June 26, 2020 at 7:33 AM

    I just came across website that can help you to get the best and top wordpress hosting >>https://www.best-wordpress-hostings.org/2/

    Loading...
    Reply

Leave a ReplyCancel reply

  • Development
  • Migration
  • Poweer Apps
  • Power Automate
  • Power Platform
  • SharePoint 2013
  • SharePoint Administration
  • SharePoint Online
  • Tips
  • Uncategorized

Best of Computers

Blog Stats

  • 67,509 hits

Subscribe

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,433 other subscribers
Buy Me Coffee
©2025 SharePoint Gems | Powered by WordPress and Superb Themes!
%d