Friday, September 12, 2014

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:

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.

Well, 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 2013 create subsite from template PowerShell

Tags: create subsite powershell sharepoint 2013, create subsite in sharepoint 2010 using powershell, create sharepoint subsite with powershell, create subsite sharepoint 2013 powershell, sharepoint 2010 powershell create new subsite, sharepoint powershell create new subsite



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...