none
confusing results for our "Custom Scripts" inside our sharepoint online RRS feed

  • Question

  • 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 2. now using the office 365 admin (who is also a sharepoint admin), i created 2 sites (modern communication site + classic team site).

    3. 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!!

    Based on the above I have the following 6 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. 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?

    6. Final question. inside this Microsoft documentation https://docs.microsoft.com/en-us/sharepoint/allow-or-prevent-custom-script   it mentioned the following about changing the "Custom scripts" at the site collection level using power-shell "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." .So can i conclude that at the end all site collections regardless of their templates (modern, classic, root, personal site & self-service site) will have the same "custom scripts" settings,, as per the sharepoint admin center?, and that defining custom scripting settings at the site collection level using this script "Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0" will not be permanent change?

    can anyone advice on these 6 question?.

    Thanks

    • Edited by johnjohn11 Thursday, January 17, 2019 8:48 PM
    Thursday, January 17, 2019 7:02 PM

All replies

  • Hi johnjohn11,

    1. Since we have enabled custom scripts inside the "SharePoint admin center", then it will take up to 24 hours until the timer job runs to turn on the custom scripting.

    If you want to apply custom scripts settings immediately, then you could use PowerShell to set custom script settings in SharePoint online.

    2. Enabling custom scripts tenant-wide applies to SharePoint MySites, Personal OneDrive sites and Any SharePoint site collection created based on self-service site creation.

    If the current site collections are in the three site collection types, then it will apply to the current 3 site collections.

    3. If you want to enable custom scripts for modern communication site collection only, then you could use the PowerShell script.

    Connect-SPOService -Url https://tenant-admin.sharepoint.com

    Set-SPOSite -Identity https://tenant.sharepoint.com/sites/contoso -DenyAddAndCustomizePages 0

    4. The script will not keep working even if you disable custom script on the site.

    5. The “users” represents the users who have the permission to run custom script in the site.

    6. Only the three site templates “SharePoint MySites”, “Personal OneDrive sites” and “Any SharePoint site collection created based on self-service site creation” will have the same custom script settings in the sharepoint admin center.

    Custom scripts tenant-wide in the sharepoint admin center will not apply to modern site.

    More references:

    Enable custom script on modern SharePoint sites to recover your favourite functionalities.

    http://sharepoint.handsontek.net/2018/10/28/enable-custom-script-on-modern-sharepoint-sites-using-powershell/

    Allow or prevent custom script.

    https://docs.microsoft.com/en-us/sharepoint/allow-or-prevent-custom-script

    How to enable custom scripts for a SharePoint site collection.

    https://www.koskila.net/how-to-enable-custom-scripts-for-a-sharepoint-online-site-collection/

    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.


    Friday, January 18, 2019 3:46 AM
    Moderator
  • Thanks a lot for your valuable reply. Can you find my comments to your reply

    1. Since we have prevented custom scripts inside the "SharePoint admin center", then it will take up to 24 hours until the timer job runs to turn on the custom scripting.

    If you want to apply custom scripts settings immediately, then you could use PowerShell to set custom script settings in SharePoint online.

    but in your below reply, you mentioned that tenant setting will only affect three site templates “SharePoint MySites”, “Personal OneDrive sites” and “Any SharePoint site collection created based on self-service site creation”.. but in this point i have created a classic team site using the global admin user, so this site should not get affected by the tenant settings for the custom scripts, is this correct?

    2. Enabling custom scripts tenant-wide applies to SharePoint MySites, Personal OneDrive sites and Any SharePoint site collection created based on self-service site creation.

    If the current site collections are in the three site collection types, then it will apply to the current 3 site collections.

    ok thanks. but does self-service sites inside "custom script" settings, cover modern team/communication sites created by non-admin users? for example if a non-admin user create office 365 group from his/her outlook, and a new modern team site got automatically created in sharepoint, will this modern team site, get affected by the tenant setting for "custom scrips"? or if non-admin user create a new sharepoint modern site from SharePoint home page, will this modern team site, get affected by the tenant setting for "custom scrips"?

    3. If you want to enable custom scripts for modern communication site collection only, then you could use the PowerShell script.

    Connect-SPOService -Url https://tenant-admin.sharepoint.com

    Set-SPOSite -Identity https://tenant.sharepoint.com/sites/contoso -DenyAddAndCustomizePages 0

    but this will be overridden by the tenant level setting after 24 hours? i mean if i enable "custom script" using powershell for the communication modern site, and i am disabling "custom script" from the tenant level,,, then the site collection will have its "custom script " disabled after 24 hours?is this correct?

    4. The script will not keep working even if you disable custom script on the site.

    i did not get your answer? do you mean "The script will keep working even if ....."??


    5. The “users” represents the users who have the permission to run custom script in the site.

    OK understood.

    6. Only the three site templates “SharePoint MySites”, “Personal OneDrive sites” and “Any SharePoint site collection created based on self-service site creation” will have the same custom script settings in the sharepoint admin center.

    Custom scripts tenant-wide in the sharepoint admin center will not apply to modern site.

    so even if the modern site is self-service site, for example created as part of creating office 365 group OR created by a non-admin user from the sharepoint home page,, then this modern site will NOT be affected by the tenant setting? in other words the self-service site that will be affected by the tenant settings are only classic sites?

    • Edited by johnjohn11 Friday, January 18, 2019 12:07 PM
    Friday, January 18, 2019 12:07 PM
  • Hi johnjohn11,

    1. Yes, if you have created a classic team site using the global admin user, then this site will not get affected by the tenant settings for the custom scripts.

    2. This modern team site will not get affected by the tenant setting for "custom scrips.

    3. The script will not keep working if you disable custom script on the site. It will throw error message after you disable custom script in the site.

    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thursday, January 24, 2019 9:22 AM
    Moderator
  • Hi johnjohn11,

    If the reply is helpful to you, you could mark the reply as answer. Thanks for your understanding.

    Best regards,

    Sara Fan

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, January 28, 2019 2:25 AM
    Moderator