Monday, January 30, 2012

PowerShell: Reset all sites to default site definition

This PowerShell script will reset all sites within a site collection in SharePoint 2010 to t heir default site definition file. Very handy after doing a migration from MOSS 2007 to SPS2010, if you run into pages being broken due to formatting, etc.

// Will reset all sub-sites in a site collection
// to their default site definition.

$sitesToReset = @("")

$sitesToReset | ForEach-Object 
 // Don't wait for user input.

        $DebugPreference = "SilentlyContinue"
        $web = Get-SPWeb $_

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

 // Reset definition.

 // Dispose site object.

No comments:

Post a Comment