How to Create a Site Collection in SharePoint using PowerShell?
PowerShell is a powerful scripting language that you can use to automate administrative tasks in SharePoint. If you’re a SharePoint administrator, then you know that there are many different ways to create site collections. This blog post will explore how to create a site collection in SharePoint using PowerShell.
We have to use the New-SPSite cmdlet to create a site collection in SharePoint. It takes URL and Owner parameters as mandatory, with several other parameters. Here is an example:
PowerShell to Create New Site Collection in SharePoint 2016:
To create a site collection using PowerShell in SharePoint, use this script.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration Variables
$SiteCollURL = "https://intranet.crescent.com/sites/Sales"
$SiteName = "Sales Team Site"
$SiteOwner = "Crescent\Salaudeen"
$SiteTemplate = "STS#0" #Team Site Template
#Create new Site Collection
New-SPSite -URL $SiteCollURL -OwnerAlias $SiteOwner -Template $SiteTemplate -Name $SiteName
Create a blank site collection in SharePoint using PowerShell
Use the template as “STS#1” to create a blank site collection in SharePoint. We can get all available site templates using the cmdlet: Get-SPWebTemplates.
SharePoint: PowerShell to create a site collection in the specific content database
Use -ContentDatabase parameter in New-SPSite to create your new site collection in an existing content database. E.g.
New-SPSite -Name "Sales" -ContentDatabase SP2013_Sales_Content -url https://Intranet.crescent.com/sites/Sales `
-OwnerAlias "Crescent\SPAdmin" -Template "STS#1"
PowerShell to create site collection without a template:
In case, you don’t provide template value, the site collection will still be created, but when the site is accessed, Users will get a prompt to choose the template for the site collection.
Please note, the PowerShell ways of creating site collections or subsites using New-SPSite or New-SPWeb doesn’t create default user groups! Here is how you can create default user groups in SharePoint: How to Create default user groups in SharePoint
To create a new site collection in SharePoint Online using PowerShell, Refer: Create SharePoint Online site collection using PowerShell
nice