Enable Save as Template option Publishing Site SharePoint Online

save as list template sharepoint online office 365

We have observed save site as template option doesn’t show in publishing sites. If you try to navigate to save site template page it will further show you below error message.

save as list template sharepoint online office 365
save as list template sharepoint online office 365

Let’s talk about the solution. We can write CSOM with PowerShell script to enable the site settings.



Please find below script and execute against site.
cls

$0 = $MyInvocation.MyCommand.Definition

$dp0 = [System.IO.Path]::GetDirectoryName($0)

$username = “sambita@***.com”

$password = “*****”

#$url = $xmldata.WebSite.Url

$url =’https://****.sharepoint.com/sites/test/’

$securePassword = ConvertTo-SecureString $password -AsPlainText -Force

# connect/authenticate to SharePoint Online and get ClientContext object..

$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)

$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)

$clientContext.Credentials = $credentials

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll”

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll”

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Publishing.dll”

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll”

if (!$clientContext.ServerObjectIsNull.Value)

{

Write-Host “Connected to SharePoint Online site: ‘$Url'” -ForegroundColor Green

$web = $clientContext.Web

$clientContext.Load($web)

$web.AllProperties[“SaveSiteAsTemplateEnabled”] = “true”

$web.Update()

$clientContext.ExecuteQuery()

}


Also read some SharePoint tutorials:

Hope this will be helpful.


You May Also like the Following SharePoint Online Tutorials:

About Sambita Rath

I have 9 years of exprience into SharePoint implementation, architecture, Administrator, development and Training.Designing Information Architecture in SharePoint 2007, 2010,2013 and Office 365.

View all posts by Sambita Rath →

Leave a Reply