"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 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 […]

SharePoint PnP logo

How to fix Add-PnPApp failing with an Access Denied error

This was a peculiar case! An issue I hadn’t run into before, and luckily a disturbingly simple fix. But first, let’s set up the scene: We were running a long-ish PowerShell script using a Global Administrator account. One part of the script was supposed to add and deploy a couple of SharePoint apps. But while running Add-PnPApp, we ran into errors: Add-PnPApp -Path $path -Scope $app.Scope -ErrorAc… , Error: {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}} […]

SharePoint PnP logo

New-PnPSite fails with “SiteStatus” : 3

While running “New-PnPSite” or actually any other site creation, method in PowerShell or programmatically, the site creation fails and you get an error like the one below back: New-PnPSite : {"d":{"Create":{"__metadata":{"type":"SP.Publishing.CommunicationSiteCreationResponse"}, "SiteStatus":3, "SiteUrl":""}}} Ouch! Where does this come from? In the code of New-PnPSite, the actual function call is shown below: var results = ClientContext.CreateSiteAsync(creationInformation); var returnedContext = results.GetAwaiter().GetResult(); (Source) So, the error is not thrown by PnP cmdlet, but rather comes from SharePoint CSOM. This is pretty normal and not surprising, but means we […]

Get-MsolServicePrincipalCredential - how to get the expiration date for a clientId

Fastest way to verify your Client Id and Client Secret are valid with PowerShell

So, you have a Client Id and a Client Secret, but don’t know if they work anymore? Maybe they are expired? Maybe someone removed them? No worries! We can use PowerShell to validate them easily! Solution By using PowerShell, it’s fairly straightforward to verify, that your Client Id and Client Secret work. See the snippets below for 2 different steps: First we validate, that the values work. If they don’t, let’s run another script to see if the Client Id exists but has expired. Validate […]

Let me explain SharePoint...

5 ways to enable Custom Scripts for a SharePoint site collection

This article explains how to enable custom scripting for any SharePoint site collection. This is functionally equivalent with setting setting “-DenyAddAndCustomizePages 0” or disabling the NoScript feature. Different instructions and solutions apply to SharePoint Online, and on-premises scenarios (SharePoint Server 2013, 2016 and probably 2019) – so see below for all of them. Different solutions are required to resolve the issue for different target sites: Modern SharePoint Team Sites (attached to Office Groups if on SharePoint Online, and without one if On-Premises) Modern SharePoint Communication […]