Fix “Sorry, You don’t have access” Access Denied Error on Save Site as Template in SharePoint Online

Problem: Getting “Sorry, You don’t have access” access denied error when trying to save site as template in SharePoint Online site from URL:

sharepoint online save as template access denied


To fix this problem, we need to enable custom scripts. Here is how to fix the access denied error on Save Site as Template.

  1. Login to SharePoint Online Admin Center
  2. Click on Settings from the left navigation >> Scroll down to “Custom Script” section
  3. Set “Allow users to run custom script on personal site” and “Allow users to run custom script on self-service created sites” options. 
    sharepoint online save site as template error
  4. Click on “OK” to save your changes.

However, this change may take up to 24 hours to reflect. To enable scripting on a particular site collection immediately, use this PowerShell script in SharePoint Online Management Shell.

PowerShell to Fix SharePoint Online Save Site as Template Access Denied Error:

Use this PowerShell script to immediately fix the access denied error on the save site as template.

#Config Parameters

#Get Credentials to connect
$Cred = Get-Credential

#Connect to SharePoint Online Tenant Admin
Connect-SPOService -URL $AdminSiteURL -Credential $Cred

#Disable DenyAddAndCustomizePages Flag
Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False

Please note, the change by PowerShell script can be overridden in the next 24 hours, If the settings don’t match! So make sure you have the same settings (either disable or enable) both in PowerShell and in SharePoint Online Admin center “Custom Script” settings.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. Passionate about sharing the deep technical knowledge and experience to help others, through the real-world articles!

4 thoughts on “Fix “Sorry, You don’t have access” Access Denied Error on Save Site as Template in SharePoint Online

  • Hi,
    I Have access to template page, but when I fill and click Ok, then I have fail with correlation id. b271d5a0-8014-7000-357a-003000eff5a4

  • Work around – Do the above, and then use the SPO Shell with “Set-SPOsite -DenyAddAndCustomizePages 0” (no quotes, obviously) and this will enable access to the template page. It doesn’t mean that it will work (as there are other considerations) but it will at least enable access.

    • Both does the same thing!
      Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False
      Set-SPOSite $SiteURL -DenyAddAndCustomizePages 0

  • Sorry, mate, this doesn’t work, even as the tenancy owner, SharePoint admin, and all the bells and whistles, it’s not allowing me through. 🙁


Leave a Reply

Your email address will not be published. Required fields are marked *