I spent many days reading about how "Custom scripts" work for sharepoint online, but i can not fully understand it. for example we have this case.

  1. inside SP admin center >> Settings >> we have custom scripts disabled as follow:-

enter image description here

  1. now using the office 365 admin (who is also a sharepoint admin), i created 2 sites (modern communication site + classic team site).

  2. so now i got these "custom script" setting for the site collections:-

    • our build-in root site collection (which is a classic team site)--> custom scripts is Disabled.
    • the modern site collection --> custom scripts is Disabled.
    • the classic team site which i created --> custom scripts is Enabled!!

so i have the following questions:-

  1. since we have prevent custom scripts inside the "SharePoint admin center", then how custom script was enabled inside the classic team site i have created?

  2. if we allow custom scripts from the "SharePoint admin center", then i assume this will affect future site collections, but will it also affect all our current 3 site collections?

  3. if i want to enable custom scripts for our modern communication site collection ONLY. so can i do so? or as a first step i will need to enable custom scripts from "SharePoint admin center" ?

  4. if i want to add a script to a classic page. can i Temporary enable custom script on the intended site >> add the custom script >> disable custom script inside the site collection? will the script keep working as-is even if we disable custom script on the site?

  5. final question inside the "SharePoint admin center" >> "Custom Script", they use the word "Prevent users" & "Allow users".. so what do users represent? does it cover office 365 & sharepoint admins? or users refer to non-admin users?

Thanks in advance for any help.

1 Answer 1


You can enable / disable Custom Scripts at the Tenant Level and at The Site level.

Please Read the following posts carefully, most of your questions will be answered:

Both pages have a matrix of the effects of this setting. Also, the second link talks about why you should not enable Custom Scripts on modern sites.

Question #1:

As per Link #1 above, wait 24 hours. It will be overridden.

Question #2:

As per documentation in Link #1, it will override the settings on the current sites until you run this command:

Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0

Question #3:

See Link #2 above.

Question #4:

As per link #1 above: If you change this setting for a user's OneDrive or a classic team site, it will be overridden by the Custom Script setting in the admin center within 24 hours.

Question #5:

"Users" all users in SharePoint. If you allow custom scripts at a tenant or site level, any one with the "Add and Customize Pages" permission level or higher will be able to add custom scripts to a site that they have that permission level (or higher).

  • ok thanks for the links, but i actually read them before multiple times. Now since you mentioned that after 24 hours the admin settings will override the settings inside the site collection, so can i conclude that at the end all site collections (modern, classic, root, personal site & self-service site) will have the same custom scripts settings,, as per the sharepoint admin center, and defining custom scripting settings at the site collection level Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0 will not be permanent change?? or this is not the case?
    – John John
    Commented Jan 17, 2019 at 18:03
  • No, the way I read it is that lets say you dont want custom scripts on any site collection except 1, you would do the following: Set the desired value at the tenant level and run the Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0 Powershell on the site you want the exception to apply to. my experience has been that the only way to un-set this property would be via powershell such as this: Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 1 Commented Jan 17, 2019 at 18:22
  • How much experience do you have with SharePoint online? 3 site collections sounds like a test farm. Do you currently have an on-prem implementation? Commented Jan 17, 2019 at 18:26
  • i did not say we only have 3 site collections, we have many site collections and some of them were created by end users, i have the 3 site collections as an example about managing custom scripts...
    – John John
    Commented Jan 17, 2019 at 18:28
  • second question, u r saying if we enable custom scripting at the tenant level and we disabled it on certain site collections, then the tenant level will not override the site collection level? if the answer is yes, then when the overriden happens?
    – John John
    Commented Jan 17, 2019 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.