One of the most common problems I see in a client built SharePoint environment is multiple site collections comingled in the same content database. While this isn’t the end of the world, it’s a problem because SLAs, security, and even back strategies are often assigned to specific databases based upon the needs of the users that will be using the site collections hosted in each database. If a site collection is not hosted in the database that the admin intended because SharePoint simply picks the first available content database with room the administrator may unwittingly incorrectly back or, even worse, fail to backup a particular site collection because it does not exist in the proper database. This is why I am a proponent of backing up at the Native SQL level but also at the site collection level.
On to the point of this article, how do I use PowerShell to create a site collection and assign the appropriate database
Create the Site Collection
First, launch the SharePoint 2010 Command Shell (do not just run PowerShell – although you can do this you have to manually import the SharePoint cmdlets. If you receive the cmdlets not found issue then you have to modify your access to the SharePoint_Config database.
Now that PowerShell is ready, the command is quite simple.
Create a new Explicit managed path that will host the site collection. In the example below we are creating the “IT” managed path.
I typically store the command in a word document so that my client’s can follow the steps sequentially, however, those of you who will maintain this responsibility I recommend you modify these commands to be a ps1 script that takes the site name, database name, site template, and managed path as parameters.
Rating: 8.3/10 (9 votes cast)
Rating: +1 (from 1 vote)
Creating one Content Database Per Site Collection In SharePoint 2010 using Windows PowerShell, 8.3 out of 10 based on 9 ratings
Ulysses Ludwig is a SharePoint architect with over 16 years in the IT and computer industry. Ulysses' primary focus is SharePoint but he dabbles in the latest web technologies and likes to develop software in his spare time.
8 Comments for Creating one Content Database Per Site Collection In SharePoint 2010 using Windows PowerShell