Wednesday, June 4, 2014

How to Create Host Named Site Collections in SharePoint 2013

In short, Host-named site collections allows you to have unique URL addresses for each site collection. Say for e.g. Instead of having a typical "Sales" site URL as:, You can have it as and for HR, it can be and so on. As per Technet, HNSC as the preferred method for deploying site collections in SharePoint 2013. So, lets see how to create host named site collection in SharePoint 2013 using PowerShell.

Host named site collections can be managed only through PowerShell as of today!
Before heading into creating Host-named site collections, There are few Points to ponder:
  • All necessary DNS entries must be created prior creating HNSC (Which is obvious!) You can create a Foward lookup zone in DNS with wildcard entry pointing to the Load balancer or Web Server's IP.
  • The web application that houses host named site collection will be created without any host headers and listening to the default port 80. So the "Default web site" of IIS must be deleted first! Also make sure no other web app is using that port without host headers. If this can't be done for any reason, You have to manually add the host header entries in the bindings in IIS on every WFE.
Although, Its possible to create site collections with unique URLs by creating separate web applications in traditionally way, Remember there is a limit of 20 web applications per SharePoint farm!

Create Host-Named Site Collections Step-by-Step:

Step 1. Create hosting Web Application for Host Named site collections:
By default, the New-SPWebApplication cmdlet creates web application in windows classic mode authentication! make sure you are providing -AuthenticationProvider switch to make it on claims authentication mode.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set variables for New web application creation
$WebAppName = "HNSC Host Web Application"

#Variables for new Application Pool
$AppPoolName = "HNSC App Pool"
#Get the existing Managed Account
$AppPoolAccount = Get-SPManagedAccount "Crescent\SvcAppPool"
#To utilize existing AppPool, Use: Get-SPServiceApplicationPool <AppPoolName>

$ContentDatabase = "SP13_HNSC_Content"
$AuthProvider = New-SPAuthenticationProvider –UseWindowsIntegratedAuthentication

#Create the web application
$WebApp = New-SPWebApplication -ApplicationPool $AppPoolName -ApplicationPoolAccount $AppPoolAccount -Name $WebAppName -Port 82 -AuthenticationProvider $AuthProvider -DatabaseName $ContentDatabase -path "C:\inetpub\wwwroot\wss\VirtualDirectories\HNSCHost" #-URL http://G1WFE01

Step 2. Create Blank Root Site collection without templates:
The root site collection should be created without assigning any template to it. So, it will be a empty-blank site.
$ServerName = "http://G1WFE01"
New-SPSite -URL $ServerName -Name "HNSC Root" -OwnerAlias "Global\SvcOwner"
The above two steps can be performed either by PowerShell or with Central Admin UI and they are one time activity. Once we have the host web application and blank root site collection ready, we can create any number of Host header site collections in it.

Step 3. Create Host Named Site collection using PowerShell
SharePoint 2013 host named site collections can be created using PowerShell only. Here is the PowerShell script to create Host-named site collection:
$HostURL = "http://WFE01"
$OwnerID = "Crescent\Support"
$OwnerMail= ""
$SiteURL = ""
$TemplateVal ="sts#0" #Team Site
#Create the HNSC
New-SPSite -url $SiteURL -HostHeaderWebApplication $HostURL -owneralias $OwnerID -owneremail $OwnerMail -Template $TemplateVal
That's all! We are done! The above script creates a host named site collection of Team site template. Hit the URL in browser and you should be able to access the site now!!

Tail: Managed Paths in Host-Named site collections:
Unlike SharePoint 2010, SharePoint 2013 allows managed paths in host named site collections. Here is how: Create a new managed path "teams"
New-SPManagedPath "Teams" –Hostheader
Once the managed path is created, we can create site collection underneath as below:
$HostURL = "http://WFE01"
$OwnerID = "Crescent\Salaudeen"
$OwnerMail= ""
$SiteURL = ""
$SiteName = "Clould Sales Team"
$TemplateVal ="sts#0"

#Get the Host named site collection by its name
$webApp = Get-SPWebApplication $HostURL
#Create new Host-named site under the managed path
New-SPSite $SiteURL -OwnerAlias $OwnerID -HostHeaderWebApplication $webApp -Name $SiteName -Template $TemplateVal
Note that, there is no UI to create managed path for host named site collections, instead we have to use PowerShell cmdlet as above.
Info: The managed paths used by HNSC are not the managed paths configured at the web application but instead they are configured on the Farm level
Host-named site collections concepts are explained in my another article: Host Named Site Collections in SharePoint. Technet article for SharePoint 2013 host named site collections with SSL, Migrating path based site collections to Host-named site collection, etc.: SharePoint 2013 Host-named site collection architecture and deployment

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...