Hi @sns
SharePoint center settings enables custom scripting in the SharePoint Online tenant. However, this change may take up to 24 hours to reflect. To enable scripting on a particular site collection immediately, use this PowerShell script through SharePoint Online Management Shell.
Also, when you enable custom scripting through the web interface, you enable it for all sites in the tenant. However, you can enable or disable custom scripting on a specific site collection through PowerShell.
Here is how to enable custom script in SharePoint Online using PowerShell at the site collection level.
#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$SiteURL="https://crescent.sharepoint.com"
#Get Credentials to connect
$Cred = Get-Credential
#Connect to SharePoint Online Tenant Admin
Connect-SPOService -URL $AdminSiteURL -Credential $Cred
#sharepoint online enable custom scripts powershell - Disable DenyAddAndCustomizePages Flag
Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False
For more information, you could refer to:
https://www.sharepointdiary.com/2017/12/how-to-enable-custom-script-in-sharepoint-online.html#:~:text=1%20How%20to%20Enable%20Custom%20Script%20in%20SharePoint,to%20run%20custom%20script%20on%20self-service%20created%20
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.