How to Create a SharePoint Site Collection with a Separate Content Database Using PowerShell ISE


Microsoft SharePoint server is having some boundaries and limits in some areas, to read more about these limits please check this article at technet.

In this article let’s focus on web application and site collection limits. When you create a new web application, SharePoint will create a new content database to contain all information about this web application and any site collection under its shield. SharePoint supports 200 GB for every content database which includes the created web application and its babies (site collections and sub-sites).

In many scenarios you will be required to create a site collection for document management purposes, which means more data size to be stored. In this case, creating a site collection with a separate content database is highly recommended approach to achieve this.

Let’s see how to create a SharePoint site collection with a separate content database using a very handy Windows server tool: PowerShell ISE

  • Step 1 – Create a new web application using SharePoint central administration
  • Step 2 – Check created content database

In this step all what you need is to open central administration then from “Application Management” section select “Manage content databases”. Select the web application to show all available content database for this web application, you can notice that by default it contains only one content database for everything.

Content databases

  • Step 3 – Open PowerShell ISE to create the script

In this step which considered the main one, we will see how to manage the whole process from PowerShell ISE console.

To open it, just type the name at start screen and select “Windows PowerShell ISE”  as administrator, DON’T use (x86) version.

ISE

First part of the script will show the required variables we need to set for the process as follow

#this line is to reference Microsoft SharePoint PowerShell namespace
#to be able to use SharePoint commands
Add-PSSnapIn Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue;
#Create command required variables
$siteName = "DMS";
$webAppUrl = "http://intranet.vlabs.local";
#You can select any site collection template code by typing Get-SPWebTemplate
$template = "STS#0";

$ownerAlias = "vlabs\ahmed.moussa";
$secondaryOwnerAlias = "vlabs\ayman.hattab";

#this variable is considering that you have a wildcard manged path "departments"
$siteUrl = "$webAppUrl/departments/$siteName";
$databaseName = "WSS_Content_$siteName";
$databaseServer = "SP2013.vlabs.local";

Second part is to create a new content database inside the selected web application to be assigned to the new site collection

 

#Create new content database for DMS department site collection
New-SPContentDatabase -Name $databaseName -DatabaseServer $databaseServer -WebApplication $webAppUrl;

Then Create the site collection and pass the content database to it as follow

#Create new site collection for DMS department
New-SPSite -Url $siteUrl -OwnerAlias $ownerAlias -SecondaryOwnerAlias $secondaryOwnerAlias -ContentDatabase $databaseName -Template $template -Name $siteName;

Last step is to create the security groups of the new site collection because SharePoint doesn’t create them by default.

#New-SPSite doesn't create default SharePoint security groups
#Create DMS site collection default groups
$web = Get-SPWeb $siteUrl;
# this symbol i:0#.w is presenting windows authentication security mechanism
$web.CreateDefaultAssociatedGroups("i:0#.w|$ownerAlias","i:0#.w|$secondaryOwnerAlias",$siteName);
$web.Update();</pre>
<pre>
  • Step 4 – Navigate to manage content databases

Now you have a new content database (200 GB) limit for the new site collection in your web application.

Enjoy this bite!

[Arabic] 15. Managing Site Collections in SharePoint Server 2013


In this lesson you will learn very interesting new topics:

– Creating site collection with a separate content database using windows PowerShell ISE
– Managing site collection owners and administrators
– Creating site collection Quotas and locks
– Creating site collection content type policy
Must watch lesson for all SharePoint administrators.