Sunday, November 6, 2016

Save site as template option is not available in SharePoint Online in Office 365


This issue most frequently occurs because the Community Sites Feature site feature, the SharePoint Server Publishing site feature, or the SharePoint Server Publishing Infrastructure site collection feature is currently enabled or was previously enabled for the affected site. 
SharePoint doesn’t support creating a template from a site where publishing or community features were enabled

More Information
Well, since the Save site as a template option is hidden from the publishing sites settings page we all used the following URL to go there directly:
Well, that is not going to work anymore in SharePoint online (SPO) if your site is a publishing site or have the publishing features activated.

In order to get around this issue you need to update a single property page value in your SPWeb object for the site you are trying to save as a template and you are good to go. The property is called SaveSiteAsTemplateEnabled. We need to set that property to true that’s all

You can use the below sample script for the same in SPO
#Load SharePoint CSOM Assemblies
[System.Reflection.Assembly]::LoadFile("C:\***\Microsoft.SharePoint.Client.dll") | Out-Null
[System.Reflection.Assembly]::LoadFile("C:\***\Microsoft.SharePoint.Client.Runtime.dll") | Out-Null
#Variables for Processing
$SiteUrl = ""
# Get a reference to the target site
$password = Read-Host -Prompt "Enter password" -AsSecureString
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("****", $password)
#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $credentials
# Update the property bag value and set it  to the string value “true”
$Context.Web.AllProperties["SaveSiteAsTemplateEnabled"] = "true"
# Commit the property change to server
Now if you navigate to the Save site as a template page using the URL directly it will show fine and it will allow you to save the site as a template which stores a copy in the Solution gallery of the site collection

No comments:

Post a Comment