How to Reset All SP 2010 Site Pages to Default Definitions with PowerShell

Written by Sean Wallbridge on. Posted in SharePoint 2010

I couldn’t get this to work for me (maybe I was having a thick day) so I asked Colin to devise a way that worked in my situation).  If you need to whack your SharePoint 2010 on the head with a big bat and make it forget all the customizations that have been perform on page and site definitions, then this is the script for you.
Replace the http://portal.somewhere.com/ part with your root site collection and Execute from the SharePoint-enabled PowerShell command line:

$site = Get-SPSite "http://portal.somewhere.com" 
$sites = @(foreach ($web in $site.AllWebs) { 
$web | Select-Object -Property Url
Write-Debug "Resetting all pages in site ($($web.Url))..."
$web.RevertAllDocumentContentStreams()
$web.Dispose() 
}) | out-File -filepath "c:Output.txt" 
$site.Dispose()

It will also output a list of the webs that were bonked to the file c:Output.txt.

Hoping the above helps someone, when they absolutely need to hard reset to definition, particularly in an ugly/adopted site collection migration scenario. (I won’t go into the gory details of the one I had the pleasure of doing)

Tags:

Trackback from your site.

Sean Wallbridge

Sean Wallbridge, President and Principal Consultant of itgroove Professional Services Ltd, is a 5 time SharePoint MVP and Evangelist from Victoria, British Columbia, Canada. Sean likes to characterize himself as a “SharePoint Jedi” (there are no experts, just those who continue to explore the enormous ways of the SharePoint force) and there is no better way to describe Sean’s enthusiasm for SharePoint! Sean and itgroove specialize in bringing a rich, professional SharePoint experience to the small and mid-size companies that form the backbone of business in British Columbia and Canada. In addition to being a SharePoint MVP, Sean has a rich background in the Windows world and carries many certifications including CISSP, MCSE, MCT and MCSA. Sean has lived and worked internationally (Bermuda) and still carries on an international consulting practice from his base at itgroove in Victoria

Leave a comment