#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog

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

koskila
Reading Time 2 min
Word Count 208 words
Comments 0 comments
Rating n/a (0 votes)
View

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

Problem

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:\> 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:

https://www.koskila.net/how-to-enable-custom-scripts-for-a-sharepoint-online-site-collection/

Did it help? It sure did for me 😉

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.

No comments yet.

Whitewater Magpie Ltd.
© 2025
Static Site Generation timestamp: 2025-08-21T07:25:10Z