How to Enable Custom Scripting in SharePoint Modern Sites

Introduction 

 
In this post, we will discuss the “Access Denied” error when you try to upload files in the library or try to create a new folder, even when you have full access to site collections.
 
Error when creating a folder in library:
 
 
 
Error when uploading file:
 
 
 
Reason
 
Scripting capabilities are not enabled with modern sites (and other sites) by default, and cannot be enabled using the admin portal for modern sites.
 
Solution
 
You can enable custom site scripting using the below PowerShell commands, even if allow custom script is selected from the admin panel. 
  1. Connect-SPOService -Url https://tenantname-admin.sharepoint.com    
  2. Set-SPOSite -Identity https:// tenantname.sharepoint.com/sites/site -DenyAddAndCustomizePages 0