We have migrated a site collection using a third party tool(the question is not related to third party tool) and observed that in the migrated site, "Pages" library pages point to an altogether different site collection's page layouts.

So i am trying to fix it using a powerhsell script. What I am looking to do is, read the URL of the page layout that is assigned to a particular page and check whether it is the correct site collection.

However, I can only get the "ServerRelativeUrl" of the page layout assigned to a page. I cannot find the absolute url property. I get the $page object of a page in the library


But there is no property for absoluteurl.


PageLayout does not expose property that stores absolute url, use PageLayout.ServerRelativeUrl property to construct full url of page layout.

Option 1

You could utilize SPSite.MakeFullUrl method to return the full URL for the specified server-relative URL of page layout, for example:

$site = Get-SPSite $siteUrl
$web = $site.RootWeb
$pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pweb.GetAvailablePageLayouts() | select { $site.MakeFullUrl($_.ServerRelativeUrl) }

Option 2

$site = Get-SPSite $siteUrl
$web = $site.RootWeb
$pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pweb.GetAvailablePageLayouts() | select { [Microsoft.SharePoint.Utilities.SPUrlUtility]::CombineUrl($site.webapplication.url,$_.ServerRelativeUrl) }


It seems you need to update page layout associated with a publishing page. PublishingPageLayout page property is used for storing page layout location.
For example, the following code demonstrates how to set page layout for a wiki page:

$wikiPage["PublishingPageLayout"] = "/_catalogs/masterpage/EnterpriseWiki.aspx, Basic Page"
  • Thanks for your response Vadim. However, the problem is, when I hover on the page layout in the "Pages" library of any page, it points to a different site collection. I want to fetch that full URL. The code that you have provided will get the available page layouts and append the site coll URL ? which i am not looking for. – Vipul Kelkar Oct 13 '14 at 14:28
  • Not exactly about appending site coll url. The specified method resolves the full url of page layout by appending web app url. – Vadim Gremyachev Oct 13 '14 at 14:32
  • Ok. but still it doesn't help me read the page layout absolute url that has got assigned to the page. The issue is only with few pages, so I need to check a condition based on that full URL that i get. – Vipul Kelkar Oct 13 '14 at 14:35
  • From your first comment it seems you are trying to update page layout url of a page, see the updated answer how to update the corresponding page property. – Vadim Gremyachev Oct 13 '14 at 16:16
  • yes i am looking to do that. I wanted to do a check to see where the current page layout is pointing to and then change it. That is why i wanted to read the absolute url of the page layout assigned to the page. Looks like I will have to change the layout for all the pages irrespective of whether the issue is there or not. – Vipul Kelkar Oct 14 '14 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.