0

In order to create a new web part page with a PowerShell script, you must provide a page layout. None of the page layouts on my site seem to match the Full Page, Vertical choice you have when you create a web part page with the UI under Choose a layout template. What page layout should I use to create a new web part page like the UI does?

1 Answer 1

0

You are looking for the values to provide for Layout template ($pageLayout)

$web = Get-SPWeb http://server/
$pagesLibrary = $web.GetList("Pages")
$pageLayout = 1
$cmd = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Method ID=\"0,NewWebPage\"><SetList Scope=\"Request\">" + $pagesLibrary.ID + "</SetList><SetVar Name=\"Cmd\">NewWebPage</SetVar><SetVar Name=\"ID\">New</SetVar><SetVar Name=\"Type\">WebPartPage</SetVar><SetVar Name=\"WebPartPageTemplate\">" + $pageLayout + "</SetVar><SetVar Name=\"Overwrite\">true</SetVar><SetVar Name=\"Title\">\"MyPage\"</SetVar></Method>"
$web.ProcessBatchData($cmd)

These are the various values you can use to set the layout templates ($pageLayout) as you need

1 - Full Page, Vertical

2 - Header, Footer, 3 Columns

3 - Header, Left Column, Body

4 - Header, Right Column, Body

5 - Header, Footer, 2 Columns, 4 Rows

6 - Header, Footer, 4 Columns, Top Row

7 - Left Column, Header, Footer, Top Row, 3 Columns

8 - Right Column, Header, Footer, Top Row, 3 Columns

1
  • This eventually worked, thank you. NOTE: Powershell's escape character is not backslash "\", it is grave accent "". So I had to edit all of the \" sequences in the $cmd string to " Mar 12, 2015 at 17:17

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.