Author Archives: SharePoint Surfer

How to Create a Custom Error Page on SharePoint

In a previous blog I explained how to Create a custom Page Not Found page on SharePoint 2010.  This is particularly useful for external facing publishing sites.

In this post I show how to add a custom error message for other types of error (4xx, 5xx).  Timeout, Bad Request etc.

  1. Firstly create your custom error page as you would create a normal page, e.g. “/Pages/ErrorPage.aspx”  Create one page for all errors or ones specific to each area you want a custom error message for.  You may want to remove these pages from the search results and navigation.
  2. Log on to your SharePoint server and naviagate to the web.config for the web application (and take a backup then) open in textpad or other editor
  3. Find the customErrors section and update as following…

If you have one page for all the errors update to

<customErrors mode="On" defaultRedirect="/Pages/ErrorPage.aspx"/>

If you create various pages for the different errors then you will need to use something like this

<customErrors mode="On" defaultRedirect="/Pages/ErrorPage.aspx">
<error statusCode="400" redirect="/Pages/Error400.aspx" />
<error statusCode="401" redirect="/Pages/Error401.aspx" />
<error statusCode="500" redirect="/Pages/Error500.aspx" />

LASTLY – do an iisreset


How to Fix – Publishing Site Content Deployment Error – Duplicate First Name Column

Content Deployment was failing with the following error in the logs:

Title: Field name already exists. The name used for this field is already used by another field in the list. Select another name and try again.

Severity: Error

Object: User Information List

We had a publishing site that was upgraded from SharePoint 2007 to SharePoint 2010 that was using content deployent from a staging site to a deployed site.

We could see using SharePoint Manager 2010 that we had duplicates in the destination site that were not in the source site.

Duplicates in destination server

We opened a job with Microsoft and we found someone with a similar issue on the msdn forums

Microsoft gave us an executable ‘RemoveDuplicateColumn64‘ to remove the duplicates, we ran it for each duplicate.

The exe prompts you for all the required parameters, one of which is the duplicate internal name which in our case was FirstName0, again we used SharePoint Manager to find the internal name.

We have no idea how these duplicates got there but since removing them a couple of months ago there have been no problems with the content deployment.

This problem could likely be avoided by using the new snapshot content deployment available in SharePoint 2010.

SharePoint 2007 to 2010 Publishing Sites Database attach upgrade gotchas!

Recently I upgraded a SharePoint 2007 content database to SharePoint 2010 using the database attach method, there were a few gotchas.

  1. Navigation not showing – displays – ‘Error’
  2. When rerunning a database attach Upgrade it fails with two errors, in the log the error is Exception: ‘Object reference not set to an instance of an object.’
  3. Page layout urls still point to the old database

Navigation not showing – displays – ‘Error’

This was an easy one, simply restart the application pool and it should go away.

Unfortunately before I figured this out I thought there had been a problem during the content database upgrade so I deleted the upgrade database and restored the 2007 database tried to rerun the upgrade, at which point I kept getting error number 2.

When rerunning a database attach Upgrade it fails with two errors, in the log the error is Exception: ‘Object reference not set to an instance of an object.’

The was also easily rectified, this happens when you try to rerun an upgrade from within the same command window as previous upgrade, close your powershell window and restart it.

Page layout urls still point to the old database

As part of the upgrade I was moving the site to a new domain, this may also be the case if you are moving a content database to another environment, say your test or development environments.

I had to download the lapontie PowerShell extensions and run the following to remove the wrong url and change it to a relative path.

Get-SPWebApplication "http://<newwebapp>" | Repair-SPPageLayoutUrl -RegexSearchString "(?:http://)" -RegexReplaceString "/"

Bulk/Batch Approval/Rejection in a SharePoint 2010 library

My client had the requirement to bulk approve or reject items in a document library or list.  Using document sets wasn’t the solution as the only thing they had in common was that they all need to be approved at the same time.

I found this excellent solution from Sohel’s blog which was almost perfect…

It handles workflow if they are running which other solutions I found didn’t.  One limitation was that it only worked for document libraries, not lists.

All I needed to do was update the elements file to below and I had it on both document libraries and lists.


















Description=Uses the notification area to display a message.

LabelText=Approve/Reject Selection






Alt=Approve multiple items


LabelText=Approve/Reject Selection













CommandAction=javascript: showApproveAll();








ScriptSrc =/_layouts/SharePoint.ApproveRejectTest/Scripts/ApproveReject.js/>


Create a custom Page Not Found page on SharePoint 2010

I’m sure all your SharePoint sites are far too great to have any internal broken links 😉

But there may be a situation when someone incorrectly links to your SharePoint site and you want to give a custom error page to provide a ‘nicer’  404 failure page and provide an opportunity for the user to seek more help or to be able to navigate elsewhere on your site.

go from this

page not found

to something like this

custom page not found

Here is how you do it

1. Create your custom ‘page not found’ page and approve it.  You probably  also want to remove it from any navigation and exclude it from search results.  I created my custom error page in the pages directory of the root site.

2. go to ..\14\TEMPLATE\LAYOUTS\1033 and take a copy of sps404.html and rename the copy to custom404.html

3. edit the file so that stsnavigate line points to the page you created in step 1


4. Open sp2010 management shell and run the following PowerShell commands (change <sitename> to your site URL)

$webapp =Get-SPWebApplication http://<sitename&gt;
$webapp.FileNotFoundPage = "custom404.html"

To redirect to a custom error page for other http errors see my other blog on How to Create a Custom Error Page on SharePoint


The Easy Way to Restore a SharePoint 2010 Content Database to a Different Domain.

If you are migrating your SharePoint site to a new domain or if you have parallel environments in another domain (e.g. for testing, development etc.)  You may wish to move a content database and all its permissions to the new domain.

Here is an easy way to do it.

  1. Create a SQL backup of the source content database
  2. Stop the SharePoint services on the destination server
  3. In SQL Management Studio restore the content database back over the destination content database
  4. Start the SharePoint services on the server
  5. Run the user migration script by SharePoint Voodoo.  WARNING:- Users need to exist in both the old and new domain.
  6. You may need to go into SharePoint designer and resave and republish your workflow, if you don’t you may get a ‘user not found’ when starting a workflow or accessing workflow settings

P.S. I doubt if this is the Microsoft recommended method!  You could also run a content deployment from the source to destination server.

How to create a empty destination site collection for content deployment

To perform a successful initial content deployment from a publishing site the destination has to be an empty site.

This is not to be confused with the <blank> site template.

I have had some success when picking the <choose template later> option in the site creation page in Central Admin but sometimes even this  fails.

The only sure way of creating a blank site is to use the following stsadm command

STSADM.EXE -o createsite -url <site-collection-url> -ownerlogin <domain\username> -owneremail <email@address>

Doing more with SharePoint with PowerShell ISE

PowerShell ISE is a much more convenient way to write and execute SharePoint PowerShell scripts, but you have to perform a few extra steps after the default installation to get PowerShell ISE up and running.

Scot Hilier has written an excellent step by step guide in how to set up PowerShell ISE for SharePoint

Once you have done that check out this Powershell cheat sheet.

Now you will never need to login to ‘Central Admin’ again

How to unquiesce farm in SharePoint 2010

 Sometimes if a back up fails or for some other reason you SharePoint sites can site can be left quiesced and/or the site collections and central admin site will be locked.

Some of the symptoms  of a quiesced or locked farm or site can be a failing content deployment, or users complaining that they can’t edit and have lost their permissions.

Unlike SharePoint 2007 you can no longer unquiesce a farm through central admin unless you add a custom solution such as the one from estruyf  .

You have to use PowerShell.  Here is the command.

stsadm -o unquiescefarm

Even after running the above command I have still found that some of sites (including central admin) are locked.

You can check you site collections and central admin site are not locked by running the following command

stsadm -o getsitelock -url http://<site&gt;

You can update/unlock using

stsadm –o setsitelock –url http://<site>  –lock none