- Browse to the Site Settings page for the site (e.g. http://cyclops/sites/Demo/_layouts/settings.aspx).
- On the Site Settings page, in the Site Actions section, click Reset to site definition.
- 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 RevertAllDocumentContentStreamsmethod 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 =
@(
"http://cyclops/sites/AdventureWorks",
"http://cyclops/sites/Demo",
"http://cyclops/sites/Toolbox"
)
$sitesToReset |
ForEach-Object {
$DebugPreference = "SilentlyContinue"
$web = Get-SPWeb $_
$DebugPreference = "Continue"
Write-Debug "Reghosting all pages in site ($($web.Url))..."
$web.RevertAllDocumentContentStreams()
$web.Dispose()
}
0 comments:
Post a Comment