Updating SharePoint 2013 page’s Page Layout using PowerShell
3 April 2013
I have just enabled SSL on our live intranet site and run the full crawl to index everything to https rather than http. Everything works fine apart from default page. It shows error, when I checked the log file it shows the following error details.
GetFileFromUrl: ArgumentException when attempting get file Url http://site url/_catalogs/masterpage/ PageLayoutName.aspx Value does not fall within the expected range.
During further investigation I found that the default page “Page layout” was still referencing to http address. The below script will update default page “page layout” URL.
$spWeb = Get-SPWeb("https://site collection URL") $spFile = $spWeb.GetFile("https://site collection URL/Pages/default.aspx") $spFile.CheckOut("Online",$null) $spFile.Properties["PublishingPageLayout"] = "/_catalogs/masterpage/SCI_HomePage.aspx, Block" $spFile.Update() $spFile.CheckIn("Update page layout via PowerShell",[Microsoft.SharePoint.SPCheckinType]::MajorCheckIn) $spWeb.Dispose()