SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of sites in which I would like to change the default Page Layout.

Is there a way to set this to a custom Page Layout using powershell? (The page layout is already on all the sites)

So far I've come up with this, but I'm not sure how to proceed:

$web = Get-SPWeb -Identity "http://whatever/"
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pubWeb.DefaultPageLayout = ?
share|improve this question
up vote 6 down vote accepted

Yes you can set the default page layout using PowerShell.

The method you are looking for is PublishingWeb.SetDefaultPageLayout() (see MSDN here:

$site = new-Object SPSite
$web = $site.RootWeb
$pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

# This code (as an example) uses the first layout as the default.
$layouts = $pweb.GetAvailablePageLayouts()
$pweb.SetDefaultPageLayout($layouts[0], $false)

share|improve this answer
Perfect thanks. Only thing I changed: $pubWeb.GetAvailablePageLayouts() | ? {$_.Name -eq "MyPageLayout.aspx"} instead of $pageLayout[0] – Abe Miessler Dec 22 '11 at 21:38
Glad to help. :) – Russell Dec 22 '11 at 21:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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