Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have been asked if it is possible to do a bulk creation of a number of pages, into the "SitePages" folder on SharePoint 2013.

I have seen some references on the web of how to achieve this via XML, but with little success.

Ideally, I would like to have an XML file, that has a structure similar to this

  • Page title
  • Page content (either flat, or HTML)

I would then see me parsing a file stored in c:\, and the powershell would loop through and create each page.

Would this be possible?

Thanks,

Rob

share|improve this question

1 Answer 1

Format your code as such. Let's say you want to create 10 new pages.

$Web = Get-SPWeb -Identity "url of your site"
$myWeb =[Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($Web)

$myLayout = $myWeb.GetAvailablePageLayouts() | Where { $_.Name -eq "BlankLayout.aspx" }

for($i=1; $i -le 10; $i++) {
   $myNewPage = myWeb.AddPublishingPage("Page" + $i + ".aspx", $myLayout)
   $myNewPage.Updated()
   $myNewPage.CheckIn("")
   $myNewPage.ListItem.File.Publish("")
  }
 $Web.Dispose()

The BlankLayout file is the layout you created for the empty pages. in the AddPublishingPage function, I am concatinating Page#.aspx with i, so it'll be Page1.aspx, Page2.aspx, so on. I think it can work like that. Just find a way to make a new page name during the loop. You can then change the number based on how many pages you would like to create.

Here is my source: http://social.technet.microsoft.com/Forums/sharepoint/en-US/12c55fb2-aa44-4d05-b793-7209da37db71/create-a-sharepoint-webpart-page-using-powershell?forum=sharepointgenerallegacy

share|improve this answer
    
Thanks for the reply. I was hoping to be able to have an XML that I could parse with my content. Is that something I could add into this code snippet? –  Rob Sked Jun 30 at 14:48

Your Answer

 
discard

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.