Create SharePoint Online Sites Using PowerShell – A Complete Guide

Create SharePoint Online Sites Using PowerShell – A Complete Guide

Imagine needing to create multiple SharePoint Online sites – each for a different team or project. Manually clicking through menus and configuring settings for each one can take hours and increase the risk of errors. Thankfully, there’s a better way! By using PowerShell, you can automate the entire site creation process in SharePoint Online. This blog post will guide you to create sites in SharePoint Online using PowerShell.

Prerequisites to Manage Site Creation in SharePoint Using PowerShell

The two main requirements to manage and create sites in SharePoint Online using PowerShell include:

  • Global administrator or SharePoint administrator privileges
  • SharePoint Online management shell

Manage SharePoint Online Site Creation Using PowerShell

Here are the PowerShell operations that we are going to discuss regarding the SharePoint Online site creation:

  1. Create a site in SharePoint Online
  2. Bulk-create SharePoint sites
  3. List all SharePoint sites using PowerShell
  4. Create groups in SharePoint Online
  5. Add users to SharePoint groups

Make sure to connect to the SharePoint Online PowerShell module and proceed with the following operations.

1. How to Create a SharePoint Site Using PowerShell?

To create a site collection in SharePoint Online using PowerShell, you can use the “New-SPOSite” cmdlet.

New-SPOSite -Url <New Site URL> -Owner <Site Owner UPN> -StorageQuota <Site Quota in MB> -Template <Template Name> -Title <Site Title>

For example, the below cmdlet creates a SharePoint Online modern team site with no Microsoft 365 group (STS#3) named ‘Business Ethics’. It assigns ownership to ‘David’ and sets a storage quota of 100 GB (102400 MB).

New-SPOSite -Url "" -Owner "[email protected]" -StorageQuota "102400" -Template "STS#3" -Title "BusinessEthics"


  • You can add additional parameters such as -LocaleID to specify the language and TimeZoneId to specify the time zone while you create sites in SharePoint Online.
  • Additionally, you can use the “Get-SPOWebTemplate” cmdlet to find site templates in SharePoint Online using PowerShell with the combination of Locale ID.
  • Creating a new SharePoint Online site collection fails if a site with the same URL exists. The creation also fails if the URL matches with the deleted SharePoint sites that exist in the recycle bin.

2. How to Create Bulk Site Collections in SharePoint Using PowerShell?

As an admin, you can use the PowerShell script for creating bulk SharePoint site collections. To create multiple SharePoint sites using PowerShell, first, you need to create a CSV file with columns like Title, Url, Owner, Template, StorageQuota, etc.

New SPO sites detail - CSV

After that, you can execute the following PowerShell script for creating SharePoint site collections with the data available in the CSV file. Make sure you change the <File Path> with the appropriate file location of the CSV file in the script.

Import-Csv '<File Path>' | foreach { 
    $siteTitle = $_.Title 
    try { 
        New-SPOSite -Url $_.Url -Owner $_.Owner -StorageQuota $_.StorageQuota -Template $_.Template -Title $_.Title -NoWait 
        Write-Host -ForegroundColor Green "The SPO site '$siteTitle' successfully created." 
    catch { 
        Write-Host -ForegroundColor Red "Error: $($error[0].Exception.Message) - The site '$siteTitle' could not be created." 

Bulk SPO site creation using PowerShell

3. How to Get All SharePoint Sites Using PowerShell?

You can list all the SharePoint Online sites created within your organization using the “Get-SPOSite” cmdlet.

Get-SPOSite -Limit All

Get and list all SharePoint sites using PowerShell

4. How to Create Groups in SharePoint Online with PowerShell?

SharePoint Online groups simplify permission management by allowing a set of users to access the site. You can utilize the “New-SPOSiteGroup” cmdlet to create a group in a site with appropriate SharePoint permission levels.

New-SPOSiteGroup -Group <New Group Name> -PermissionLevels <Permission Level> -Site <Site URL>

For example, the following command will create a group named ‘Site Editors’ in the ‘Technical Support’ site with ‘Edit access’ permissions.

New-SPOSiteGroup -Group "Site Editors" -PermissionLevels "Edit" -Site ""

Create SharePoint online groups using PowerShell

Furthermore, you can utilize the capabilities of other PowerShell cmdlets to efficiently manage SharePoint Online users and groups. You can easily update groups, add or remove users, and even export SharePoint Online site users for streamlined administration. PowerShell also enables you to audit SharePoint Online group membership to retrieve the changes performed.

5. How to Add Users to SharePoint Group Using PowerShell?

Assigning users to specific SharePoint groups grants them the necessary permissions to access or edit content within a SharePoint site. This ensures controlled access and data security.

To add a user to a SharePoint Online group on a site collection, you can use the “Add-SPOUser” cmdlet.

Add-SPOUser -Group <Group Name> -LoginName <User’s UPN> -Site <Site URL>

For example, the following cmdlet will add the user ‘Allen’ to the ‘Site Editors’ group within the ‘Technical Support’ site.

Add-SPOUser -Group "Site Editors" -LoginName "[email protected]" -Site ""

Add a user to a SharePoint Online group

Similarly, you can use the “Remove-SPOUser” cmdlet to remove users from SharePoint Online groups. Additionally, by iterating through a list of users in a CSV file, you can efficiently remove or add bulk users to SharePoint groups using PowerShell.

We hope this guide empowers you to create sites in SharePoint Online and manage them using essential PowerShell operations. You can also leverage the power of PowerShell to enhance your SharePoint Online security with dedicated SPO PowerShell scripts. Feel free to reach out through the comments section if you have any questions.

Create SharePoint Online Sites Using PowerShell – A Complete Guide

by Thiraviam time to read: 3 min