kwizcom banner advertisement

Reset to Site Definition via PowerShell in SharePoint

To Re-ghost customized SharePoint sites and pages, We use "Revert to Site definition" via
  • Site Settings >> under Site Actions section, click on Reset to site definition 
  • Choose a specific page or entire site. Click on Reset! .
Reset to Site Definition using PowerShell in SharePoint
Reset to site definition - what does it do?
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 gets deleted and the version on the file system (the Site Definition version) is used.

Reset to Site Definition via PowerShell
When you have to reset a Site or List to its definition in bulk, PowerShell can be utilized.
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$WebURL ="https://intranet.crescent.com/sites/operations/us"

$web =  Get-SPWeb $SiteURL
$web.RevertAllDocumentContentStreams();
$web.Update()
Lets do it for All sites under the site collection:
$SiteURL ="https://intranet.crescent.com"

#Revert all webs to site definition
Get-SPSite $SiteURL | Get-SPWeb | foreach-object {
 $_.RevertAllDocumentContentStreams()
 Write-Debug "Site Resetted: $($web.Url)"
 } 
 All customizations will be reverted once the operation completed.
Reset to Site Definition via PowerShell in SharePoint Reset to Site Definition via PowerShell in SharePoint Reviewed by Salaudeen Rajack on December 23, 2014 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.