SharePoint 2010 - How to set custom access denied page

To set a custom access denied page, we use SharePoint PowerShell Cmdlet and the following snippet set the custom access denied page and uses Get-SPCUstomLayoutsPage to verify the custom page.


$web = Get-SPWebApplication http://SharePoint:3000/
Set-SPCustomLayoutsPage -Identity AccessDenied  –RelativePath "/_layouts/CustomPages/CustomAccessDenied.aspx" -WebApplication $web
$web = Get-SPWebApplication http://SharePoint:3000/
Get-SPCustomLayoutsPage -Identity AccessDenied -WebApplication $web | Format-List
Here are list of custom pages you can set -
  • AccessDenied
  • Confirmation
  • Error
  • Login
  • RequestAccess
  • Signout
  • WebDeleted
 Best practice is to create a folder under the _layouts folder and copy the existing pages for any customization.

To learn more about the cmdlet and available options, check this URL - http://technet.microsoft.com/en-us/library/ff607768(v=office.14).aspx

 Note: the example given in the above Technet microsoft link has a bug, see the highlight in the below screenshot from the site*.


Identity Type must be one of the following, and not like the url given on the technet example:
  • None
  • AccessDenied
  • Confirmation
  • Error
  • Login
  • RequestAccess
  • Signout
  • WebDeleted
and here is the screenshot for the error if you use the technet example -



*Source - http://technet.microsoft.com/en-us/library/ff607768(v=office.14).aspx

Comments