2

I have a PowerShell script in which I first create a new site collection, then fetches the SPWeb object of the sitecollection and then set some properties.

Due to a specific error, I have instead opted for creating the site collection from Central Administration instead of from the PowerShell script. This is where the weird things start to happen.

When I create the site collection from PowerShell with the below code, I can fetch the SPWeb without any errors.

New-SPSite -URL $root$managedPath$relativeUrl -ownerAlias $ownerAlias -Template $template -Language 1053    

..

$web = Get-SPWeb $root$managedPath$relativeUrl

When I create the site collection through Central Administration and tries to fetch the SPWeb object, I get the following error

Get-SPWeb : Cannot find an SPWeb object with Id or Url ...

Further more, when I run Get-SPSite to view all available sites, the sites differ between those that have been created using PowerShell, and those via the Central Administration console.

Url                                                     CompatibilityLevel  
---                                                     ------------------  
https://rootsite/createdViaPowershell1                          15                  
https://rootsite/createdViaCentralAdmin                                           
https://rootsite/createdViaPowershell2                          15                  

I'm using the BLANKINTERNET#0 web template in PowerShell, and selects "Publishing portal" when creating from Central Administration.

How come the result differs, and how can I create a site collection identical to those created in Powershell, but instead from Central Administration?

1 Answer 1

2

Publishing Portal maps to "BLANKINTERNETCONTAINER#0" and not "BLANKINTERNET#0", which is specific to subsites.

You can verify this or any other site template from the site creation page by using your browser's dev tools and looking at the select option that represents the site you're trying to create:

enter image description here

5
  • Thanks Derek, for pointing that out! Do you happen to know if there is any way to create a BLANKINTERNET#0 site collection through Central Admin?
    – Daniel B
    Aug 5, 2015 at 14:20
  • No, you can't do that, and you wouldn't want to, because it does not contain everything you need for a functioning publishing site. Aug 5, 2015 at 14:27
  • Alright! I'll have to work around the issue with my original error. What is it that PowerShell does differently when creating the new site collection though, since I can use the BLANKINTERNET#0 template there?
    – Daniel B
    Aug 5, 2015 at 14:31
  • I seem to remember from a previous project that there were downstream issues when creating a site collection using that template, although I don't recall exactly what they were. Make sure the Publishing Infrastructure feature is activated, and try looking at the master page gallery and content types, and verify that all the stuff you'd expect to see is in there. Aug 5, 2015 at 14:38
  • The original problem we're facing is that those site collections created with BLANKINTERNET#0 are throwing The context has expired errors every now and then. Perhaps it might be related to the issues you are describing.
    – Daniel B
    Aug 5, 2015 at 15:13

Your Answer

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

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