Last active
August 29, 2015 14:14
-
-
Save Na0mir/2672bdff7e152f2a4703 to your computer and use it in GitHub Desktop.
Get all pages located in "Pages" library and change theirs page layout.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------------------------------------- | |
# Author: Romain Blanchard | |
# Date: 20.06.2012 | |
# Description: Get all pages located in "Pages" library and change theirs page layout. | |
# ---------------------------------------------- | |
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue | |
# Variables | |
$spweb = Get-SPWeb -Identity "http://rbla-sp2010-002/sites/migration/audit/" | |
$spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spweb) | |
$pages = $spPubWeb.PagesList | |
write-host "" | |
foreach($item in $pages.Items) | |
{ | |
$pubPage = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item) | |
$url = new-object Microsoft.SharePoint.SPFieldUrlValue($pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout].ToString()) | |
if($url -ne $null) | |
{ | |
$newurl = new-object Microsoft.SharePoint.SPFieldUrlValue("http://rbla-sp2010-002/sites/migration/_catalogs/masterpage/BlankWebPartPage.aspx, Blank Web Part page") #Location, Title | |
write-host "Page : $pubPage.Name" -foregroundColor Yellow | |
$pubPage.CheckOut() | |
$pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $newurl | |
$pubPage.ListItem.UpdateOverwriteVersion() | |
$pubPage.ListItem.File.CheckIn("Page layout fixed.", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn); | |
} | |
} | |
write-host "" | |
write-host "-----------------" | |
write-host "" | |
write-host "Done." -foregroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment