kwizcom banner advertisement

Create SharePoint Site Collection in New / Existing Content Database with PowerShell

Requirement: Create site collection in new database
Having a dedicated content database for each site collection is recommended for larger SharePoint site collections.

Create site collection in new content database in SharePoint 2010 using PowerShell:
As the Central Administration doesn't provide any direct interface, lets use PowerShell cmdlet to create site collection in new content database for SharePoint 2010 / SharePoint 2013:
#Create a New Content Database
New-SPContentDatabase -name SP2010_Content_Sales -webapplication http://sharepoint.crescent.com

#Create a Site collection in the specific content database
New-SPSite -Name "Sales" -ContentDatabase SP2010_Content_Sales -url http://sharepoint.crescent.com/sites/Sales/ -OwnerAlias "global\User1" –SecondaryOwnerAlias "corp\user2"
The above PowerShell script creates new content database and creates site collection in that particular database. Here, Use "-ContentDatabase" parameter to set the target content database.

But wait, this will not stop SharePoint from placing new site collections to the content database created (SP2010_Content_Sales)! we've to set the MaxSiteCount and WarningSiteCount values to control any future sites.
$SiteURL= "http://sharepoint.crescent.com/sites/Sales/"
#Get the Content Database of the site collection and set Maximum & Warning levels for the Sites.

Get-SPContentDatabase -Site $siteURL | Set-SPContentDatabase -MaxSiteCount 1 -WarningSiteCount 0

PowerShell script to create site collection in a existing content database:
If you want to create new site collection in an existing content database, use this PowerShell script: Say, we've an existing content database: SP2013_Content_Sales and want to create our new site collection in it.

This PowerShell creates site collection in specific content database.
Add-PSSnapin Microsoft.SharePoint.PowerShell

$SiteURL = "http://sharepoint.crescent.com/sites/Sales"

#Set exisiting Content Database
$DatabaseName = "SP2013_Content_Sales"

$PrimaryOwner = "Global\SPFarmAdmin"

$SecondaryOwner = "Global\Salaudeen"

#Create new Site collection on the specific content database
New-SPSite $SiteURL -OwnerAlias $PrimaryOwner -SecondaryOwnerAlias $SecondaryOwner -ContentDatabase $DatabaseName

If you don't want to use PowerShell, its still possible to create site collection in new content database using STSADM and with a Central Admin tweak! Here are the workarounds: Create site collection in new / specific content database SharePoint 2007 

Tags: create site collection in new database, sharepoint 2013 create site collection with existing database, create sharepoint site collection own content database, sharepoint site collection separate content database, sharepoint 2013 create site collection new database PowerShell
Create SharePoint Site Collection in New / Existing Content Database with PowerShell Create SharePoint Site Collection in New / Existing Content Database with PowerShell Reviewed by Salaudeen Rajack on 1:49 PM Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.