Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

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

$
0
0
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 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 = "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

Viewing all articles
Browse latest Browse all 1058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>