Share via

SharePoint Online

Andreea Ruth Moldovan 21 Reputation points
2021-01-07T14:23:55.88+00:00

Hello, I would like to save a SharePoint site as a template in the power shell, what would be the commands for this operation?(I mention that I use SharePoint online 2019
thanks.

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments

Answer accepted by question author

Jerry Xu-MSFT 7,961 Reputation points
2021-01-08T02:29:45.237+00:00

Hi, @Andreea Ruth Moldovan ,

For saving site as template, try to use the script below. Make sure you have enabled saving site as template before. It works in my lab SharePoint 2019 farm

$WebURL = "http://your-site-collection-URL"  
   
#Get the Web Object  
$Web= Get-SPWeb $WebURL  
   
#Variables for Save site as template settings  
$TemplateName ="PMO Site Template"  
$TemplateTitle ="PMO Project Site Template"  
$TemplateDescription ="Site template for PMO project management portal"  
   
#Option to Save with content  
$SaveWithContent= 1  #0 otherwise  
   
#Save site as template programmatically with PowerShell  
$Web.SaveAsTemplate($TemplateName,$TemplateTitle,$TemplateDescription,$SaveWithContent)  

Reference: https://www.sharepointdiary.com/2014/08/save-site-as-template-sharepoint-2013-using-powershell.html#ixzz6iv4ABPIL


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Andreea Ruth Moldovan 21 Reputation points
    2021-01-08T14:01:33.867+00:00

    Thanks for the reply!
    another question is, why do I get this error:
    "Sorry, something went wrong
    Error exporting the list named "appdata" at the URL: _catalogs/appdata
    TECHNICAL DETAILS

    Troubleshoot issues with Microsoft SharePoint Foundation.
    Correlation ID: 16479f9f-9076-b000-91f7-6b506b5bc3e1

    Date and Time: 1/8/2021 5:52:02 AM" ?

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.