Saturday, September 21, 2013

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

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

#Create a Site collection in the specific content database
New-SPSite -Name "Sales" -ContentDatabase SP2010_Content_Sales -url -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= ""
#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 specific 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 = ""

#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

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...