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 = "https://demo.pccs.com/hr/" #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.
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 = "https://intranet.crescent.com/travel/" #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