Wednesday, November 23, 2016

Create Site collection with New Content database in SharePoint

In many scenarios you will be required to create a site collection with new Database to satisfy database growth/flexible site collection, which can later move to different web application.

Let’s see step by step how to create a SharePoint site collection with a separate content database using Powershell for SharePoint.


Create a managed path under web application : 
Go To Central Admin >> Application Management >> Create Site Collection

Select Defined managed Paths

Enter Site collection name and Type "Explicit Inclusion"

Click on "Add Path".


Now we need to create Content Database to host the site collection. Remember we only have Defined managed path and not created Site Collection Yet.

Run below command under Powershell window:

New-SPContentDatabase -Name "WSS_Content_test" -DatabaseServer "Servername"  -WebApplication "http://xyz:6001/test"

$ContentDatabase = Get-SPContentDatabase "WSS_Content_test"

Above command will create Content Database on SQL server.


In Final step we need to create site collection with new content database we just created.

Define all parameters:

$url = "http://xyz:6001/test"
$ContentDatabase = "WSS_Content_test"
$WebsiteName = "Test"
$WebsiteDesc = "Site test portal"
$Template = "STS#1"
$PrimaryLogin = "domain\adminuser"
$PrimaryDisplay = "Admin"
$PrimaryEmail = ""

Execute the command:

New-SPSite -Url $url –ContentDatabase $ContentDatabase -Name $WebsiteName –Description $WebsiteDesc  -Template $Template -OwnerAlias $PrimaryLogin –OwnerEmail $PrimaryEmail

Site template we selected STS#1 is for blank website. Incase you need to explore more template types, please refer this wonderful article.

Taaada!! Site collection is created with new content database in just three steps.

Contact me


Email *

Message *

Total Pageviews