Creating Host Named Site Collections

The following is based on the Exam Ref 70-331: Core Solutions of Microsoft SharePoint Server 2013 by Troy Lanphier.

Check out Kirk Evan’s blog for more background behind HNSC – http://blogs.msdn.com/b/kaevans/archive/2012/03/27/what-every-sharepoint-admin-needs-to-know-about-host-named-site-collections.aspx

#Build a web application and place an empty site collection in it, a site collection with no site, e.g. pick site later or create with powershell as follows:

$applicationPool = "SharePoint - 443"

$ServiceAcct = "domain\content" #Account normally used when creating a web app via guie, atin

$svcacctmail = "content@domain"

$WebApp = "SharePoint HNSC Web Application"

$webAppURL = "https://ws2013app/"

$contentDB = "WSS_Content_TopSiteEmpty"

#If creating for SharePoint 2013, sent the claims authentication provider by calling the new-spauthenticationprovider cmdlet into a variable as: $Provider = New-spauthenticationprovider

#Create the example web application, as mentioned above, either with gui, and pick later, or

New-SPWebApplication -ApplicationPool $applicationPool -ApplicationPoolAccount $serviceAcct -Name $WebApp -Port 443 -databaseName $contentDB -securesocketslayer

#If doing for 2013

New-SPWebApplication -ApplicationPool $applicationPool -ApplicationPoolAccount $serviceAcct -Name $WebApp -Port 443 -AuthenticationProvider (New-SPAuthenticationProvider) -databaseName $contentDB -secureSocketsLayer

#If you get a pound sand message on first attempt to load the SP 2013 site, navigate to the settings page under <URL>/_layouts/15/settings.aspx and deactivate MDS

#Now that the web app is there, build the empty site collection

$primarySiteCollectionOwnerAcct = "domain\someName"

$PrimarySCOwnerEmail = "webcontent@domain"

New-SPSite -URL $webAppURL -OwnerAlias $primarySiteCollectionOwnerAcct -OwnerEmail $PrimarySCOwnerEmail

#Build some content databases

new-SPContentDatabase -Name $HNSC1DB -WebApplication $WebApp -WarningSiteCount 0 -MaxSiteCount 1

#Now build some HNSC's

$HNSC1Name = "Hockeytown Usa"

$HNSC1URL = "https://hockeytown.domain.com"

$HNSC1DB = "WSS_Content_HockeyTown"

New-SPSite -url $HNSC1URL -HostHeaderWebApplication $webAppURL -Name $HNSC1Name -ownerAlias $PrimarySiteCollectionOwnerAcct -owneremail $PrimarySCOwnerEmail -contentDatabase $HNSC1DB

$HNSC2Name = "Baseball city"

$HNSC2URL = "https://baseball.domain.com"

$HNSC2DB = "WSS_Content_HaveYouSeenMyBaseball"

New-SPSite -url $HNSC2URL -HostHeaderWebApplication $webAppURL -Name $HNSC2Name -ownerAlias $PrimarySiteCollectionOwnerAcct -owneremail $PrimarySCOwnerEmail -contentDatabase $HNSC2DB