Bulk SharePoint Online Site Collection Creation using PowerShell

create site collection in sharepoint online using powershell

Purpose of the article: The purpose of this SharePoint online article is to provide instruction on how to create SharePoint Online site collections in bulk using PowerShell.

The scope of the article: The scope of the article is to give detailed guidelines to understand and create SharePoint Online site collection.

Creating SharePoint Online Site Collection can be done using 2 methods:

  • PowerShell Script for bulk creation
  • Manual

Create SharePoint Online Site Collections in Bulk using PowerShell Script

We can create site collections in bulk in SharePoint online. Here we will see how we can create site collections from an excel file.

Creation of Site collection will be done through PowerShell Script using the below step:

Create a CSV file with the column name shown in below screenshot:

Bulk SharePoint online site collection creation powershell
Bulk SharePoint online site collection creation PowerShell

Sample CSV file: You can download the sample CSV file which I have used in this example.

The CSV file contains the information of the site collection which need to be created:

  • Site Collection URL: E.g. https://domainname.sharepoint.com/teams/SALES ‘domainname’ your domain name.
  • Owner: A user who is responsible for the site collection
  • Site collection Admin: The same user as owner or different user depending upon the requirement.
  • ResourceQuota: Using 300 resource quota default and the reason behind accepting the default is that if you are creating a site collection with team site template and if you are not going to use any sandbox custom solution. A custom solution requires high server resource quota. If the site collection is highly customized, then require high server resource quota.
  • StorageQuota: Put the number of gigabytes (GB). Minimum would be 1 GB and maximum would be 25600 GB (25 TB).
  • Template: Use Team site template ID STS#0.
  • Title: E.g. SALES with the above example.
  • TimeZoneId: Depending upon the requirement that means in which timezone the site collection should be stamped.

Open a Window PowerShell as administrator and run the Connect-SPOService cmdlet as shown below:

create a new site collection in sharepoint online using powershell
create a new site collection in SharePoint online using PowerShell

NOTE: Before running the above cmdlet, please make sure that the SharePoint Online management shell tool and it’s all modules are installed on the system. Also, check the execution policy is set as per the requirement.

Then supply the value and that value would be https://domainname-admin.sharepoint.com which is the URL of SPO admin center.

Then click enter, which will open a pop window to verify the credentials as shown below:

You can use Global administrator/SharePoint Administrator credentials to authenticate.

Then edit the below script and make sure to change the $AdminName and $csvfile = Import-csv “File Path”:

$AdminURL = “https://domainname-admin.sharepoint.com/”

$AdminName = “”

$csvfile = Import-csv “”

#User Names Password to connect

$SecurePWD = read-host -assecurestring “Enter Password for $AdminName”
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $SecurePWD
#Connect to SharePoint Online

Connect-SPOService -url $AdminURL -credential $Credential

#Add Site collection Admin

foreach($row in $csvfile)
{
Write-Host “Creating $($row.”Site Collection URL”)”
New-SPOSite -url $row.”Site Collection URL” -Owner $row.owner -Template $row.Template -Title $row.Title -ResourceQuota $row.ResourceQuota -StorageQuota $row.StorageQuota -TimeZoneId $row.TimeZoneId
Set-SPOUser -site $row.”Site Collection URL” -LoginName $row.”Site Collection Admin” -IsSiteCollectionAdmin $True
}

Download SharePoint Online bulk Site Creation PowerShell Script.

NOTE:

  • $AdminName: This will be the same UPN which was used as Global administrator/SharePoint Administrator.
  • $csvfile = Import-csv “File path”: In this put the path of CSV file that you have created in beginning.
  • Make sure to store CSV file and script on the same location.
  • If everything is properly executed, then you will see the New site collection is created and will appear in the URL list in SharePoint Admin center under site collection section.

Create SharePoint Online Site Collection manually from SharePoint  Online Admin center

Log in to office 365 portal using Global Administrator or SharePoint Administrator credentials. If you have not tried Office 365, you can sign up for an Office 365 Enterprise E3 trial.

Select the app launcher icon in the upper-left and choose Admin to open the Office 365 admin center. In the left pane, select Resources, and then select Sites.

how to create a new sharepoint site in office 365
how to create a new SharePoint site in office 365

Select add a site.

create site collection sharepoint online powershell
create site collection SharePoint online PowerShell

If the admin doesn’t see the options above, then click on App launcher and then from Admin center tab click on SharePoint as shown below:

sharepoint powershell create site collection
SharePoint PowerShell create a site collection

It will take admin on the below landing page:

sharepoint online powershell create new site collection
SharePoint online PowerShell create a new site collection

Then click on the New tab and then Private Site Collection as shown in the above screenshot:

create site collection in sharepoint online using powershell
create site collection in SharePoint online using PowerShell

Once an admin clicks on Private Site Collection, a new window will pop up as shown below:

Admin must fill all the details as shown in above screenshot.

  • In the Title box, enter a name for the site collection.
  • In the Web Site Address, use ‘teams’ or ‘sites’ as a managed path, URL will be created.
  • In the Template Selection section, in the Select a language drop-down list, select a language for the site collection. Admin can enable the SharePoint multiple language interfaces on sites, but the primary language for the site collection will remain the one that has been selected here by admin.
  • NOTE: It’s important to select the appropriate language for the site collection because once it’s set, it cannot be changed. After creating a site collection, verify the locale and regional settings are accurate. (For example, a site created for Chinese will have its locale set to China.)
  • In the Template Selection section, under Select a template, choose the Team site template as per requirement.
  • In the Time Zone box, select as per the requirement.
  • In the Administrator box, type the username of your site collection administrator.
  • In the Storage Quota box, type the number of gigabytes (GB). Minimum would be 1 GB and maximum would be 25600 GB (25 TB).
  • In the Server Resource Quota box, use 300 resource quota default and the reason behind accepting the default is that if you are creating a site collection with team site template and if you are not going to use any sandbox custom solution. The custom solution requires high server resource quota. If the site collection is highly customized, then require high server resource quota.
  • Click on OK.

Read my previous article on Disable or Hide Sync Button at SharePoint Online Site and Document Libraries Level.

I hope this article helps you guys to create a site collection in SharePoint online from SharePoint Online admin center. Also, it will help to create SharePoint site collections in bulk using PowerShell in SharePoint online.


You May Also like the Following SharePoint Online Tutorials:

About Anup Bhavsar

This is Anup Bhavsar currently working as an Consultant for Atos Global IT Solutions and Services Private Limited. I am passionate about Microsoft technologies like Office 365,SharePoint Online, SharePoint Servers, Azure and love to contribute to the Office 365, Azure community.

View all posts by Anup Bhavsar →