Create Site Collection With New Managed Path and Content Database

In this article I would like to share the PowerShell script that does the following:

  1. Create new content database
  2. Create new managed path
  3. Create new site collection

PowerShell Script

The following is the PowerShell Script that does that:

# Add Snap in

If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )

{

    Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell

}

 

# Create Content Database

New-SPContentDatabase -name "DATABASE-NAME" -WebApplication "http://WEB-APP-URL"

 

# Create Managed Path

New-SPManagedPath -RelativeURL "path/subpath" -WebApplication "http://WEB-APP-URL" -Explicit

 

# Create Site Collection

New-SPSite http://WEB-APP-URL/path/subpath -OwnerAlias DOMAIN\user -Name "Site Collection Title" -Template "STS#0" -ContentDatabase "DATABASE-NAME"

Confirmation

You can verify the new site using the URL:

Create-Site-Collection-with-New-Managed-Path- in-SharePoint-1.jpg
You can verify the new managed path through "Central Administration"  > "Main Page"  > "Select web application" > "Managed Paths" (toolbar item).

Create-Site-Collection-with-New-Managed-Path- in-SharePoint-2.jpg

You can verify the new content database through "Central Administration" > "Main Page" > "Manage Content Databases" link.

Create-Site-Collection-with-New-Managed-Path- in-SharePoint-3.jpg

Create-Site-Collection-with-New-Managed-Path- in-SharePoint-4.jpg

The same PowerShell script is attached with this article.

Summary

In this article we have explored the PowerShell script to create a new site collection with a new managed path & content database.  I hope this will be useful for site conversion activities.


Similar Articles