Saturday 5 November 2016

Creating a Site Collection using script

Today I am providing the Power Shell Script that create a Site collection “host named” or normal on the given web application on the given database.

Inputs
Site collection URL : Provide the new site collection URL.
HostHeader Web Application (Optional): Provide the webapplication URL that will host this collection(in case of Hosted Site Collection). This is optional field and can be left blank if you have provided the webapplication URl in the Site collection.
Database Name (Optional): Provide Database name where you want to move above site collection. Database must already exists in web application. This is optional field.
Site name : Provide Site Collection Name
Description (Optional) : Provide Site Collection Description
Site template : Provide Site template that will be used to create the site
Primary Login : Primary user name (Primary Site Collection Administrator)
Site Primary email (Optional) : Primary administrator email if any.
Secondary Login (Optional) : Secondary user name (Secondary Site Collection Administrator)
Secondary email (Optional) : Secondary administrator email if any.

Outputs
This script will Create a new site collection on the given database on the given web application.

Example-
.\scriptname.ps1
.\scriptname.ps1 | out-file “FilePath\Filename.txt”

Dependencies –
if you are creating a site collection on specific Database then database must exists in the given webapplication.
if you are creating hosted site collection then you have to follow additional steps from this url. http://hostnamedsc.blogspot.in/2016/05/host-named-site-collection-is-not.html
For executing this script user must be added in site collection administrators given site.
User should have Shell Admin rights to run the scripts.
Run Management Shell as an Administrator.
How to execute -
Copy this script and paste in Note pad.
Save this file as .ps1.
Run this script in SharePoint Management Shell. You can run this script in PowerShell as well.
Follow on screen instructions.

FOR ANY HELP ON THIS SCRIPT USE "GET-HELP .\SCRIPTNAME.PS1 --FULL" AFTER SAVING THIS FILE.
Go to above link to get the script.



No comments:

Post a Comment