Technology Toolbox

Your technology Sherpa for the Microsoft platform

Jeremy Jameson - Founder and Principal



Use PowerShell to "Reset to Site Definition" in SharePoint Server 2010


In one of my posts last month, I provided the following steps to "reghost" all of the pages in a Team Foundation Server (TFS) project site:

  1. Browse to the Site Settings page for the site (e.g. http://cyclops/sites/Demo/_layouts/settings.aspx).
  2. On the Site Settings page, in the Site Actions section, click Reset to site definition.
  3. On the Reset Page to Site Definition Version page, click the option to Reset all pages in this site to site definition version, and then click Reset.

Today, I was about to perform this process manually on several sites, but then I decided to spend a few minutes exploring the Reset Page to Site Definition Version page (e.g. http://cyclops/sites/Demo/_layouts/reghost.aspx).

That's when I discovered the SPWeb.RevertAllDocumentContentStreams method. [I'm actually a little embarrassed that I wasn't aware of this little gem before. A few years ago, while working on the Agilent Technologies project, I'd used some custom C# to reghost specific pages (to resolve deployment issues), but I clearly recall some general "wonkiness" with it. If I'd known about the RevertAllDocumentContentStreams method a few years ago, I probably would have just run that as part of each and every deployment ;-) ]

Anyway, once you know about the method, it's very easy to call it from PowerShell.

Here's a little script to reset all pages in a list of sites to the site definition version:

$sitesToReset =

$sitesToReset |
    ForEach-Object {
        $DebugPreference = "SilentlyContinue"
        $web = Get-SPWeb $_

        $DebugPreference = "Continue"
        Write-Debug "Reghosting all pages in site ($($web.Url))..."


  1. # re: Use PowerShell to "Reset to Site Definition" in SharePoint Server 2010

    August 24, 2011 11:44 PM

    Sweet, this is exactly what I was looking for. Ran across this issue today which will require me to set 25+ sites back to site definitions and this will save tons of time. Already tested with my Test system. Thanks.

Add Comment

Optional, but recommended (especially if you have a Gravatar). Note that your email address will not appear with your comment.
If URL is specified, it will be included as a link with your name.

To prevent spam from being submitted, please select the following fruit: Cherries

Please add 3 and 7 and type the answer here: