I am creating Site Collections for Testing SharePoint. I am using Host Named Site Collection to do that instead of the path based site collection addressing.

For that

  1. Got a reference to the HNSC web application which I created before using web application management.
  2. created a non-templated site at the root of the web applications for workflow to connect.

    New-SPSite -Name "Root HNSC Site Collection" -Url "http://vspserver -HostHeaderWebApplication $hnscWebApp -OwnerAlias "vspserver \Administrator"
  3. but when I try to create a Team site by using the following scrpit:

    New-SPSite -Name "VSPServer Intranet" -Url "http://intranet.vspserver" –HostHeaderWebApplication $hnscWebApp -Template "STS#0" -OwnerAlias "vspserver\Administrator"

I get this error message:

    New-SPSite : Cannot find an SPWebApplication object that contains the
    following Name, Id, or Url: http://intranet.vspserver.test-lab.local.
    At line:1 char:1
    + New-SPSite -Name "SPServer Intranet" -Url
    "http://intranet.vspserver.test-lab.lo ...
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletNewSite:
       SPCmdletNewSite) [New-SPSite], SPCmdletPipeBindException
        + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSite

Any idea would be appreciated.


2 Answers 2


I think you need to use a template variable and use Get-SPWebTemplate instead. Begin with asigning your $template variable by this script:

$template = Get-SPWebTemplate "STS#0"

Then use the $template variable in your creation script:

New-SPSite -Name "VSPServer Intranet" -Url "http://intranet.vspserver" 
–HostHeaderWebApplication $hnscWebApp -Template $template 
-OwnerAlias "vspserver\Administrator"

Reference: Create a site collection in SharePoint 2013

  • I tried that but getting the same Error message. Dec 12, 2012 at 10:19
  • The point is I cannot create a team site. I though I create a new URL but it seems from the Error that it cannot be found, so is it something that I create beforehand? Dec 12, 2012 at 10:21
  • This does not resolve the issue. Jun 30, 2015 at 17:15

The issue you are experiencing is that the cmdlet cannot properly pipe SPWebApplication object. (at least from the error) If you try:

$w = Get-SPWebApplication http://intranet.vspserver.test-lab.local.

You should get an error as well, maybe more descriptive this time.

Other thing is that I can defo see an issue with your URL, is it correct that it resolves to the '(...)local.' That dot/'.' on the end looks quite suspicious.

The other issue you may be having (if I understand correctly) is that you have created a root site. Then you try to create a team site at 'http://intranet.vspserver' which is root site. You cannot overwrite a site collection this way, you should be creating new at 'http://intranet.vspserver/sites/teamsite'.

Other bit to check is how is your host file wired you should wire the http://intranet.vspserver to the local host (pretty normal for lab and dev machines)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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