Create SharePoint Site Collection in a specific Content DB In SharePoint using PowerShell
As the SharePoint Central Administration doesn’t provide any interface to create a site collection with a nominated content database, we need to use PowerShell commands to create a site collection in a new content database for SharePoint on-premise.
#Create a SharePoint New Content Database
New-SPContentDatabase -name <<WSS_Content_DB_Name>> -webapplication <<http://Web_App_URL>>
Create Site Collection in the previously created Content DB
#Create a Site collection in the specific content database
New-SPSite -Name "<<Site_Collection_name>>" -ContentDatabase <<WSS_Content_DB_Name>> -url <<Site_Collection_URL>> -OwnerAlias "domain\primary_Admin" -SecondaryOwnerAlias "domain\Secondary_admin" -Template "BLANKINTERNET#0"
Here the template is the required site collection template.
Some of the common template codes are below:
Team Site: STS#0
Blank Site: STS#1
Wiki Site: WIKI#0
Blog: BLOG#0
App Catalog Site: APPCATALOG#0
Publishing Site: BLANKINTERNET#0
Project Site: PROJECTSITE#0
My Site Host: SPSMSITEHOST#0
But this will not stop SharePoint from adding new site collections to the content database created above. We have to set the MaxSiteCount and WarningSiteCount values to 0 to control any future sites.
$SiteURL= "<<Site_Collection_URL>>"
#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
#Create a SharePoint New Content Database
New-SPContentDatabase -name <<WSS_Content_DB_Name>> -webapplication <<http://Web_App_URL>>
Create Site Collection in the previously created Content DB
#Create a Site collection in the specific content database
New-SPSite -Name "<<Site_Collection_name>>" -ContentDatabase <<WSS_Content_DB_Name>> -url <<Site_Collection_URL>> -OwnerAlias "domain\primary_Admin" -SecondaryOwnerAlias "domain\Secondary_admin" -Template "BLANKINTERNET#0"
Here the template is the required site collection template.
Some of the common template codes are below:
Team Site: STS#0
Blank Site: STS#1
Wiki Site: WIKI#0
Blog: BLOG#0
App Catalog Site: APPCATALOG#0
Publishing Site: BLANKINTERNET#0
Project Site: PROJECTSITE#0
My Site Host: SPSMSITEHOST#0
#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
Comments
Post a Comment