Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
What does the URL say? Post full stack trace please –  Anders Rask Dec 11 '12 at 20:25
    
ULS log, not url –  Anders Rask Dec 11 '12 at 20:26
    
@ Anders Rask, I don't get what you mean. where can I get that from? –  user1847609 Dec 12 '12 at 10:27
    
@user1847609 You can find exceptions in the ULS log. Here is a guide: View diagnostic logs in SharePoint 2013 –  Benny Skogberg Dec 12 '12 at 19:55

1 Answer 1

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

share|improve this answer
    
I tried that but getting the same Error message. –  user1847609 Dec 12 '12 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? –  user1847609 Dec 12 '12 at 10:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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