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.
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?
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 😉
- How to resolve “Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF” - June 30, 2020
- How to resolve persistent “Build started… Build failed.” when trying to run Entity Framework Core commands? - June 24, 2020
- SharePoint Home Sites – a Game Changer? - June 16, 2020