"Set-PnPAvailablePageLayouts -AllowAllPageLayouts" returning an error "Access denied. You do not have permission to perform this action or access this resource.."

How to fix “Access denied” errors when running “Set-PnPAvailablePageLayouts”?

This post was most recently updated on April 28th, 2019.

Reading Time: < 1 minute.

This article describes one way how to fix seemingly non-sensical “Access denied” errors, that you get when running Set-PnPAvailablePageLayouts.

Problem

Table of Contents

While running the PnP cmdlet for enabling or selecting the available publishing page layouts for a web, you run into this, fairly generic error: Access denied. You do not have permission to perform this action or access this resource.

PS C:\&gt; Set-PnPAvailablePageLayouts -AllowAllPageLayouts
Set-PnPAvailablePageLayouts : Access denied. You do not have permission to perform this action or access this resource.
At line:1 char:1
+ Set-PnPAvailablePageLayouts -AllowAllPageLayouts
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Set-PnPAvailablePageLayouts], ServerUnauthorizedAccessException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Publishing.SetAvailablePageLayouts

This error is thrown on some sites, but not all. This happens despite you having global administrator permissions on the tenant. What gives?

Solution

The reason for this is actually kind of an old friend of ours. Enabling different layouts actually requires custom scripts to be enabled for your site!

Hence, this ended up being another easy and kind of obvious one.

The error message wasn’t very informative, but it went away after enabling custom scripts. So, with any luck, you’ll just need to enable Custom Scripts on the site – see this article for instructions:

Did it help? It sure did for me 😉

Antti K. Koskela

Antti Koskela is a proud digital native nomadic millennial 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.
mm

Leave a Reply

avatar
5000
  Subscribe  
Notify of