kwizcom banner advertisement

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 site with "Blank" template!. Here is how to create SharePoint subsite using PowerShell:

Create Subsite in SharePoint 2013 using PowerShell
Add-PSSnapin "Microsoft.SharePoint.Powershell" -EA SilentlyContinue

#Define value for Variables
$SiteTitle = "Human Resource"
#URL for you new subsite
$SiteUrl = "http://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 subsite, New-SPWeb cmdlet should return URL of the subsite as in the above screen.
create sharepoint subsite with powershell

If there is no value for Template parameter is given, SharePoint prompts 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, lets 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 = "http://demo.pccs.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
How to Create a Subsite in SharePoint with PowerShell? How to Create a Subsite in SharePoint with PowerShell? Reviewed by Salaudeen Rajack on September 12, 2014 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.