Resetting the Site Definition Via PowerShell in SharePoint

First we need to understand what a Site Definition is and why we are resetting the option. A Site Definition is the core definition of what a site is in SharePoint.

  • A Site Definition is installed on file system of web front ends, located at ..\12\Template\SiteTemplates. This directory is language-neutral.
  • A Site Definition consists of .aspx pages and XML files with the Collaborative Application Mark-up Language (CAML).
  • A major benefit is that the Page and List definition is read locally from the file system, not from Content Database.
  • A Site Definition Page and List definition are cached at IIS process startup.
  • Customizations made to a Site Definition are stored in a content database, not on the file system. This can be done via SharePoint Designer, or when custom site templates are saved.
Reference: MSDN

Procedure: Site Settings >> Site Actions>> Reset to Site Definition



Reset to Site Definition removes any customizations and reverts the file back to the version originally deployed via the Site Definition. Customized pages are stored in the Content Database (a copy with changes) and are called unghosted. When you reset, the customized copy is deleted and the version on the file system (the Site Definition version) is used.



Enter the Local Site URL and you will get Pop-up notification.



If you select another Check box option in this page then you will get the following popup.



Reset the Site Definition using PowerShell Script: Entire siteCollection
  1. $SiteURL ="https://gauti.sharepoint.com"  
  2. $web = Get-SPWeb $SiteURL  
  3.  
  4. #Revert all webs to Site Definition  
  5. Get-SPSite $SiteURL | Get-SPWeb | foreach-object {  
  6. $_.RevertAllDocumentContentStreams()  
  7. Write-Debug "Site Resetted: $($web.Url)"  
  8. }  
  9.   
  10. Specific list/Site  
  11. Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue  
  12.   
  13. $WebURL ="https://gauti.sharepoint.com/sites/apps"  
  14.   
  15. $web = Get-SPWeb $SiteURL  
  16. $web.RevertAllDocumentContentStreams();  
  17. $web.Update()  
Thanks for reading my article. I hope you have enjoyed it.