On one of our customer’s new Office 365 tenant we were unable to upload files to the SitePages library. An access denied was given to every user, even the tenant admin.
After investigating the issue, we noticed something odd when checking the permission of our user in the library’s permissions:
Even when having sufficient permissions in SharePoint, we have a deny on adding and customizing pages.
The solution is to enable custom scripting on the tenant (https://[tenantname]-admin.sharepoint.com/_layouts/15/online/TenantSettings.aspx). Beware that this setting might take 24 hours to reflect.
This setting was already configured likewise at our customer’s tenant, so it was time for some PowerShell magic.
Note that you need the SharePoint Online Management Shell to execute the script below.
Connect-SPOService -url [https://yourdomain-admin.sharepoint.com] Set-SPOSite -Identity https://yourdomain.sharepoint.com -DenyAddAndCustomizePages $false
Beware that the scripting setting in the admin portal matches the PowerShell setting, or the site collection setting may be overridden again within the next 24 hours.
Once the command has been executed, you should be able to upload pages without an access denied.