How to Create a Subsite in SharePoint with PowerShell?

Although creating subsites can be easily managed from SharePoint Web UI, We can also use PowerShell cmdlet New-SPWeb to create subsites programmatically in SharePoint. This is extremely helpful when you have to create a bunch of subsites under any SharePoint 2010/2013 site collection or when you have to create subsites in bulk Or when the SharePoint UI doesn’t provide an option to create a site with a “Blank” template!

Create a Subsite in SharePoint using PowerShell

Are you looking for a way to create a new subsite in SharePoint using PowerShell? This blog post will show you how to use PowerShell to create a subsite in SharePoint. We will also show you how to configure specific settings for your subsite, such as its title and description.

Add-PSSnapin "Microsoft.SharePoint.Powershell" -EA SilentlyContinue

#Define value for Variables
$SiteTitle = "Human Resource"
#URL for you new subsite
$SiteUrl = ""
#Templte to be assigned to the subsite
$WebTemplate = "STS#0" #Team Site template

#create subsite using powershell sharepoint 2010/SharePoint 2013
New-SPWeb -Name $SiteTitle -Url $SiteUrl -Template $WebTemplate 

On successful creation of a subsite, New-SPWeb cmdlet should return the subsite URL as in the above screen.

create sharepoint subsite with powershell

If there is no value for the Template parameter is given, SharePoint prompts you to select a web template when you open the subsite for the first time. While the above script simply provides an easier way to create subsite using PowerShell, let’s explore other options such as permissions, navigation, etc. in creating subsites in SharePoint 2013 using PowerShell:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for site creation
$SiteTitle = "Purchase Portal"

#Site description
$SiteDescription ="Portal for Purchase Department Portal"

#URL for you new subsite
$SiteUrl = ""

#Templte to be assigned to the subsite
$WebTemplate = "STS#0" #Team Site template

# AddToTopNav -  Adds the new site within the top navigation of the site collection
# UseParentTopNav  - Replicates the top navigation of the site collection into the new subsite
# UniquePermissions  - Instructs not to inherit permissions from the site collection

#create subsite using PowerShell SharePoint 2010/SharePoint 2013
New-SPWeb -Name $SiteTitle -Description $SiteDescription -Url $SiteUrl -Template $WebTemplate  -AddToTopNav -UniquePermissions -UseParentTopNav 

Related post:  SharePoint PowerShell to create new subsite from template SharePoint 2013 create subsite from template PowerShell

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

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