Custom script for the site collection

sns 9,246 Reputation points
2022-07-26T17:38:25.39+00:00

I have noticed custom script enabled already at the SharePoint online admin center settings, but still in one scenario error is coming warning message like custom script need to be enabled
Please let me know why it is happening? do we need to do anything at site collection level related to custom? If yes how to test custom script at site collection level and how to enable it?

Microsoft 365 and Office SharePoint For business Windows
{count} votes

Accepted answer
  1. Yi Lu_MSFT 17,611 Reputation points
    2022-07-28T07:07:50.603+00:00

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.