Before reading this article, please go through the following article:
- Introduction
- Document Objective
- Audience
- Creating Site Collection and then sub site within same site collection.
- Creating Sub Site under already created Site collection.
- PowerShell Script
Introduction
- Document Objective
The purpose of this document is to provide instructions on using this PowerShell script to create site collections and sites in SharePoint using different web templates.
- Audience
This document is targeted to developers and architects responsible for creating site collections and sites using multiple combinations with different web templates. Please note that root site collection must be present with web application URL. The code can be modified and extended as per requirements.
Creating Site Collection and then sub site within same site collection
Procedure
- Go to Start > Open SharePoint 2013 Management Shell.
- Run as administrator.
- Run the script.
- Enter Web application url. Press Enter.
- It will validate the web application url. If root site collection is present at web application url, it will ask if user wants to create site collection or sub site.
- Enter 1. It will ask the site collection details. Enter Site Title, Site description and Site Url (must be a valid URL) URL is pre-populated in ‘e.g’ part. User can use this URL.
- After entering all details, it will ask for web template category choice.
Enter 1. Then, it will ask for web template for this particular web template category.
Enter 1 for Team Site.
- Enter Primary administrator and Secondary Administrator (optional) details.Press Enter.
- Site Provisioning process will take place.
- After Site Collection got provisioned, it will ask if user wants sub site to be created under newly created site collection.
- Enter “y”. It will ask for Sub Site details. Enter these details.
- Site Provisioning process will take place.
- After successfully provisioning the site, it will ask if another sub site to be created under same site collection.
- Enter “y” if user wants another sub site to be created under same site collection. Otherwise enter “n”.
- Then it will ask if another site collection under same web application to be created.
Enter “y” if user wants another site collection to be created under same web application. Otherwise enter “n”.
- Then it will ask if another Site collection or sub site to be created. Enter “y”.
- User can follow steps 5 to 13 to create multiple site collections and sub sites with different web templates.
Creating Sub Site under already created Site collection
Procedure
- Go to Start > Open SharePoint 2013 Management Shell.
- Run as administrator.
- Run the script.
- Enter Web application url. Press Enter.
- It will validate the web application url. If root site collection is present at web application url, it will ask if user wants to create site collection or sub site.
- Enter 2.
- Enter the site collection url under which the sub site is to be created.
It will validate the entered site collection URL.
- Enter the sub site details. Select ‘Records Center’ web template from ‘Enterprise Site template’ category.
- As Records center needs Publishing feature to be activated on parent site collection. So first Publishing feature is activated at parent site collection and then sub site will be provisioned.
- After provisioning sub site successfully, it will ask if another sub site to be created within same site collection.
- Enter “y” if user wants another sub site to be created under same site collection. Otherwise enter “n”.
- Then it will ask if another Site collection or sub site to be created. Enter “y” if user wants another site collection or sub site to be created. Otherwise, enter “n”.
PowerShell Script