Category Archives: PowerShell

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

STSNavigate("/Pages/PageNotFound.aspx");

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"
$webapp.update()

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


references 

http://support.microsoft.com/kb/941329

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