SharePoint PnP logo

New-PnPSite fails with “SiteStatus” : 3

This post was most recently updated on December 4th, 2018.

While running “New-PnPSite” or actually any other site creation, method in PowerShell or programmatically, the site creation fails and you get an error like the one below back:

New-PnPSite : {"d":{"Create":{"__metadata":{"type":"SP.Publishing.CommunicationSiteCreationResponse"},"SiteStatus":3,"SiteUrl":""}}}

Ouch! Where does this come from? In the code of New-PnPSite, the actual function call is shown below:

var results = ClientContext.CreateSiteAsync(creationInformation);
var returnedContext = results.GetAwaiter().GetResult();

(Source)

So, the error is not thrown by PnP cmdlet, but rather comes from SharePoint CSOM. This is pretty normal and not surprising, but means we can’t debug it that much, as CSOM is not open source.

Alright – what can we do to fix this? There’s a couple of things – but first, let’s take a look into the call itself and its SiteStatus value!

What does SiteStatus in that response mean?

Okay – your New-PnPSite didn’t seem to result in a new site being created, but rather you got an error and a status code that doesn’t tell you much. What now?

My understanding of the status codes is the following:

  • 1
    • We’re getting there! Please wait, you’ll get your site eventually.
    • Throttling or high resource usage means you’ll get your site a bit later.
    • Implement a logic for backing off or sleeping.
  • 2
    • Site created, you’re good!
    • Should also return the URL.
  • 3
    • Fatal error. All hope is lost.
    • You’ll need to handle this in your code, by implementing a fallback logic or just handling the error.

Weirdly enough, the best source I have for these status messages is this conversation on GitHub: https://github.com/SharePoint/PnP-PowerShell/issues/1179

Reasons and resolutions

Multiple reasons can cause the issue. One of the most typical ones from my experience is that the URL was already in use.

Sounds simple, right? However, this doesn’t mean that there actually would be a site with that URL. The URL is still reserved also for removed sites that are in the recycle bin, and there’s no GUI for removing these sites from said bin.

Luckily, we do have PowerShell commandlets to do this task for us!

Below is the PowerShell commandlet to see which sites are in the second stage recycle bin:

Connect-SPOService -Url "[tenant-admin.sharepoint.com]"
Get-SPODeletedSite

To get rid of one or more of them, you can call Remove-SPODeletedSite. See this blog article on how to do that: https://www.koskila.net/remove-spodeletedsite-actually-remove-sharepoint-online-site/ !

What else could be wrong?

Okay – maybe it wasn’t your fault, after all! If the site wasn’t in the recycle bin and PnP libraries work as they should, it’s only this site creation that’s not working… Well, maybe it was Microsoft messing it up all along! This might especially be the case, if the issue persists for site creation using different methods (GUI, CSOM, 3rd party tools) and different URLs.

There’s a bug ticket about this reported on PnP GitHub, but truthfully, I don’t think the issue is ever in the PnP code – it’s usually an underlying issue in the datacenter: https://github.com/SharePoint/PnP-PowerShell/issues/1542

The resolution could be to just contact Microsoft Support and get them to flip a switch. Sorry – no silver bullets here! 🤔

The following two tabs change content below.

Antti K. Koskela

Solutions Architect / Escalations Engineer at Koskila / Norppandalotti Software / Valo Solutions
Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world. He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff. This is his personal professional (e.g. professional, but definitely personal) blog.

Let me know your thoughts!