Create a Site Collection in SharePoint within specific Content Database
Applicable to: SharePoint 2010/2013/2016
Generally, site collections are created using the Central Administration. However, this means doesn’t gives us the option to select the specific Content Database where we wish for the site collection to reside.
Well, PowerShell comes to the rescue again. Below is the PowerShell script that can be used to create the site collection in the specific content database we intend to. Change the input parameters and run the snippet as per need.
The Code:
$myURL = "https://mysharepoint.com/sites/mysitecollection" $myContentDB = "myContentDatabaseName" $mySCName = "mydesiredSiteCollectionName" $mySCDesc = "mydesiredSiteCollectionDescription" $PrimaryLogin = "DOMAIN/User" $mySCTemplate = Get-SPWebTemplate "STS#0"
New-SPSite -Url $myURL –ContentDatabase $myContentDB -Name $mySCName –Description $mySCDesc -Template $mySCTemplate -OwnerAlias $PrimaryLogin
Description of Parameters:
Command | Usage |
New-SPSite | The command for creating a new site collection at the specified URL |
-URL | The desired URL of the site collection that is to be created |
-Content Database | This logs in the specified content database name where the new site collection will be created |
-Name | The name of the site collection that is to be created |
-Description | The description of the site collection that is to be created |
-Template | This represents the web template type of the site collection (eg: Blank Site- STS#1, Team Site – STS#0, etc). Click here for the entire code of templates |
-OwnerAlias | This is the primary site collection administrator |
4,615 total views, 2 views today
0 Comments