SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
1  
@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

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
    
This does not resolve the issue. – NotVonKaiser Jun 30 '15 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)

share|improve this answer

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.