1

I am configuring SharePoint Server 2013 for Host-Named Site Collections & creating Initial Site Collections.

Created a new Web Application to handle Host-Named Site Collections (HNSC):

i)Created a new IIS web site: (1) Name: SharePoint HNSC Host – 80 (2) Port: 80

ii) Application Pool: (1) Created a new application pool: (2) Application Pool Name: SharePoint Default HNSC AppPool

Created a default, not template site collection at the root of the web application: a) Opened SharePoint 2013 Management Shell:

$hnscWebApp = Get-SPWebApplication | Where-Object {$_.DisplayName -eq "SharePoint HNSC Host - 80"}

New-SPSite -Name "Root HNSC Site Collection" -Url "http://????" -HostHeaderWebApplication $hnscWebApp -OwnerAlias "????\Administrator"

New-SPSite -Name "????" -Url "http://????" –HostHeaderWebApplication $hnscWebApp -Template "STS#0" -OwnerAlias "????\Administrator"

New-SPSite -Name "????" -Url "http://????" –HostHeaderWebApplication $hnscWebApp -Template "DEV#0" -OwnerAlias "????\Administrator"

But I am getting an error message "" New-SPSite: cannot find an SPWebApplication object that contains the following name""

Can someone help me to replace ???? with correct values please?

3
  • 1
    I see you make the IIS web site and app pool, was this done in IIS manually or via the add web application in Central Admin? Dec 4, 2012 at 17:31
  • I am trying to add a site collection by the SharePoint 2013 management shell. Dec 12, 2012 at 10:06
  • when you get the $hnscWebApp object, explore it, try just typing in the object name by itself. it should return the display name and the URL. Dec 12, 2012 at 13:35

1 Answer 1

1

I would like to point you to the corresponding technet page:

Deployment and configuration for host-named site collections

Lets do this from the beginning

#get the one web app that will hold all host named site collections
$hnscWebApp = Get-SPWebApplication | Where-Object {$_.DisplayName -eq "SharePoint HNSC Host - 80"}

#get the url of the web app
$hnscWebAppUrl = $hnscWebApp.Url
#the variable will hold for example: http://hnsc-hostwebapp.company.local

#the hnsc web app hosting all hnsc should have a root site collection
New-SPSite -Name "Root HNSC Site Collection" -Url "$hnscWebAppUrl" -OwnerAlias "YOURDOMAIN\Administrator"

#create a new hnsc with a dedicated url
New-SPSite -Name "Teamsite" -Url "http://teamsite.company.local" –HostHeaderWebApplication $hnscWebApp -Template "STS#0" -OwnerAlias "YOURDOMAIN\Administrator"

#create a dedicated dev site on a dedicated url
New-SPSite -Name "SPDev site" -Url "http://spdev.company.local" –HostHeaderWebApplication $hnscWebApp -Template "DEV#0" -OwnerAlias "YOURDOMAIN\Administrator"

#create a managed managed path for hnsc
New-SPManagedPath "sites" -HostHeader

#create a path based site on a hnsc team url
New-SPSite -Name "Teamsite for Marketing" -Url "http://teamsite.company.local/sites/marketing" –HostHeaderWebApplication $hnscWebApp -Template "STS#0" -OwnerAlias "YOURDOMAIN\Administrator"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.