I'm trying below code to add File to Site Pages -
Add-PnPFile -Path 'C:\Temp\myfile.aspx' -Folder "SitePages"
but getting "Access denied" .
I have checked permissions for my user under
https://acme.sharepoint.com/sites/my-site/_layouts/15/user.aspx and found that my user gets the "Deny Add and Customize Pages" message, which probably explains why I'm not allowed to run the
Why I am getting the
Deny Add and Customize Pages message is what's puzzling me, though.
I've created a permission level called
admin permissions in which every permission (including
Add and Customize Pages) is checked, and created a group
admins which use that permission level. I've added myself to that group, and made sure I'm not a member of any other groups (i.e. "Owners", "Members", "Visitors") on that site.
So why do I still get the "Access denied" error message when running
Add-PnPFile? In my (powershell) script I've also added
Set-SPOSite -Identity <path/to/site> -DenyAddAndCustomizePages $false but still no luck.
Any help in debugging this will be appreciated.