A SharePoint Site Collection has disappeared or been deleted, how do I restore it?

So you come in of a morning and you have a whole host of e-mails from users complaining that content isn’t working for them. You visit the main page, no issues, but then you go to visit a site in another collection… and you receive a dreaded 404 error:

This error (HTTP 404 Not Found) means that Internet Explorer was able to connect to the website, but the page you wanted was not found. It’s possible that the webpage is temporarily unavailable. Alternatively, the website might have changed or removed the webpage.

Checking the recycle bin shows that the web is still active, and so it appears that there’s something wrong with the Site Collection.

Although not present in the front end thankfully there’s a cmdlet to allow you to quickly view deleted collections and then you can look to restoring them.

Which will allow you to view the deleted collections. Click here for documentation.

Once you have a list of your collections you can then restore them using

Here’s an example we had with a client –

We identified that the services site collection had gone rogue and couldn’t be found anywhere. We’ve then run Get-SPDeletedSite to see if by chance it had been deleted, which by chance it had and showed in the results:

Example of Get-SPDeletedSite

Thankfully this means that the solution is easy – using

Restored the site immediately (without any downtime or ISS recycling being necessary) and makes it available again to users:

Example of Restore-SPDeletedSite

The interesting problem is always how a collection was deleted in the first place. Interestingly enough in this particular case it looks like a user had received the automated e-mail asking them to confirm whether a SharePoint Web site is still in use, much like the following:

From: SharePoint
Sent: Wednesday, 8 July 2015 12:00 AM
To: Administrator
Subject: Confirm SharePoint Web site in use

Please follow the link below to your SharePoint Web site to confirm that it is still in use.

If the site is not being used, please go to http://sharepoint/services/_layouts/settings.aspx, and select “Delete This Site” to remove the Web site.

You will receive reminders of this until you confirm the site is in use, or delete it.

The user following this link and then confirming that they would like the web (in this case not a web but a collection) deleted the collection. A good lesson in always revisiting who is an administrator of what – in this case the user managed to delete a collection without  central admin!

SharePoint deployment scope, solution and features

SharePoint Features

SharePoint Features can be scoped to the Farm, Web Application, Site Collection, and Web Site level depending on the purpose of the feature. The Feature scope is determined by the setting of the Scope attribute in the Feature element defined in the feature.xml file.

A sample Feature element tag is given below:

<Feature Id="F62C96CF-79FD-44be-8882-E9BFBD199184">
Title="Feature Title"
Description="Feature Description"

Web Site scoped Feature (Scope=”Web”):

A Web Site scoped Feature is one that can be activated only at the individual Web site level. List templates, list instances, custom actions, event receivers, etc are the some common elements for web site scoped features. Web Site scoped features can be activated by using:

Run the following STSADM command:

Site Collection scoped Feature (Scope=”Site”):

A Site Collection scoped Feature is one that can be activated at the site collection level and contains items that apply to the site collection as a whole (for example, content types that are shared across the site collection), as well as items that can be activated per site (for example, list instances, etc). Site Collection scoped features can be activated by:

Run the following STSADM command:

Web Application scoped Feature (Scope=”WebApplication”):

A Web Application scoped Feature is one that can be activated at the web application level and contains items like administrative web application links, delegate control registrations, feature/site template association, document form registrations, etc. A farm Feature can contain, for example, links to /_layouts pages and files, /_admin pages, and other elements. Web Applicationscoped features can be activated by using:

Run the following STSADM command:

Farm scoped Feature (Scope=”Farm”):

A Farm scoped Feature can be activated at the server farm level. A farm Feature contains a number of elements that are critical for implementing applications and logic anywhere within a deployment. A farm Feature can contain, for example, links to /_layouts pages and files, /_admin pages, and other elements. Farm scoped features can be activated by using:

Run the following STSADM command:

SharePoint Solutions

SharePoint solutions are either deployed globally or targeted to a particular web application. The decision of which is made automatically by the SharePoint Solution framework depending on the contents of the solution manifest. Exception to this rule are Sandbox solutions which are managed on the site collection level.

Globally Deployed Solutions

When a solution is deployed globally, the assembly DLL file will go and sit under windows\assembly folder. All SharePoint application pools, including Central Administration’s, are recycled automatically. This can be good and bad. This is good because any GAC installed DLL that has been upgraded needs to be reloaded. This can be bad though with regards to the availability of your entire SharePoint Farm.

Web Application Targeted Solutions

When a web application targeted solution is deployed or retracted, the assembly DLL file will go and sit under the inetpub\websitename\bin folder. Only the application pools of the targeted web applications are recycled. When deploying and retracting a web application targeted solution, deploy or retract it only to those web applications that will use it … thus preventing unnecessary recycling of application pools.

Sandbox Solutions

Sandbox solutions are deployed to the site collection. This new mechanism has been introduced in SharePoint 2010 to provided more isolation between deployed components. Sandbox Solutions deployment does not require application pool recycle and does not allow deploying DLLs into the GAC, as everything is stored in content database where site collection resides. These solution also provide much more restrictive execution model and limited access to SharePoint API.

PowerShell Code to deploy solutions (WSP)

PowerShell to deploy the WSP to the GAC on server and deploy to all URLS

PowerShell to deploy the WSP to the GAC on server and deploy only to 1 specific web application (not in bin folder)

PowerShell to deploy to specific webapplication at bin folder on server

PowerShell to deploy to all the webapplication at their bin folders on server