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 = ?

1 Answer 1


Yes you can set the default page layout using PowerShell.

The method you are looking for is PublishingWeb.SetDefaultPageLayout() (see MSDN here: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.publishingweb.setdefaultpagelayout.aspx)

$site = new-Object SPSite http://mysite.com
$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)

  • Perfect thanks. Only thing I changed: $pubWeb.GetAvailablePageLayouts() | ? {$_.Name -eq "MyPageLayout.aspx"} instead of $pageLayout[0] Commented Dec 22, 2011 at 21:38
  • 1
    Glad to help. :)
    – Russell
    Commented Dec 22, 2011 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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