Enable SharePoint Save Library as Template using PowerShell

Eric Gregorich

SharePoint has traditionally had a way to create lists and libraries from an existing template. For example, you could go into the list or library settings and click Save List/Library as Template.

However, in SharePoint Online, this functionality is being replaced by a more "modern" approach. So, Microsoft removed this ability from settings.

For lists, you can now click "New > List > From an Existing List." A friendly interface appears for selecting an existing list from any current site. Unfortunately, this does not work for document libraries.

One option for Document Libraries is to create a Site Design. A Site Design consists of Site Scripts, which consist of JSON that defines the structure of a site, including any lists and libraries. After creating a Site Design, a user (with appropriate permissions) can apply the Site Design to their site at any time. The lists and libraries in the Site Script(s) will be created or updated on the site.

Another option that works (for now) is to enable the old Save Library as Template functionality. You can do this using some PowerShell. The PowerShell allows for custom scripts on the current site (which are now disabled by default on modern sites). Allowing custom scripts then causes the Save Library as Template link to reappear in the library settings.

$AdminCenterURL = "https://yoursharepointurl-admin.sharepoint.com/"
$SiteURL="https://yoursharepointurl.sharepoint.com/sites/yoursite"
Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)
Set-SPOSite $SiteURL -DenyAddAndCustomizePages $False