Updating SharePoint 2013 page’s Page Layout using PowerShell

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.Properties["PublishingPageLayout"] = "/_catalogs/masterpage/SCI_HomePage.aspx, Block"
$spFile.CheckIn("Update page layout via PowerShell",[Microsoft.SharePoint.SPCheckinType]::MajorCheckIn)

See More Articles

Contact us

To begin your digital transformation, get in touch.

We’re pleased to address any inquiries you might have and assist you in selecting the service that best suits your requirements.

Your benefits:
Speak To Us