Sometimes
you end up in a solution where someone have been kind enough to use SharePoint
Designer to edit a Page Layout. This means that you are not able to change the
Page Layout through your deployed code, in a package. Changes made in the
development environment doesn’t show up in production. Your Page Layout is in a
Ghosted mode of its origin, and we need to Un-Ghost the Page Layout to be able
to change it from a package created in our development environment.
Thus you
use this script to first find out which Page Layouts have been changed, and
uncomment the Revert Content Stream to actually change the Page Layout back to
an UnGhosted mode.
$s = Get-SPSite https://siteCollectionUrl
$w = $s.RootWeb
$ps = New-Object Microsoft.SharePoint.Publishing.PublishingSite($s)
$pls = $ps.PageLayouts
foreach ($pl in $pls)
{
$f = $w.GetFile($pl.ServerRelativeUrl)
if ($f.CustomizedPageStatus -eq "Customized")
{
Write-Host
Write-Host "Layout page name: " -NoNewline
Write-Host $f.Name
Write-Host "Status before: " -NoNewline
Write-Host $f.CustomizedPageStatus
#$f.RevertContentStream()
Write-Host "Status after: " -NoNewline
Write-Host $f.CustomizedPageStatus
}
}
$w.Dispose()
$s.Dispose()
Thanks mate, very helpful
ReplyDelete