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

We are considering migrating from one system to SharePoint. Assuming I can correctly read the existing pages, how would I automate the addition to our SharePoint system ?

share|improve this question

I use the following block of Powershell to update an existing wiki page. The tricky bit was the pre-formatted block of 'boilerplate' html in the "ows_WikiField" field that wraps the page content. If the content wasn't wrapped properly in this html, it wouldn't work correctly.

As stated, this block of code updates an existing page. Creating a new page would just involve initializing a new item and adding it to the list. You could then set the content of the page as demonstrated below. If you're trying to do this in .Net, I'm sure the objects below should exist in the SharePoint .Net libraries.

$contentHtml = "<div class=`"ExternalClass3AE60CA79C8141549A06FBE602010C07`"><table id=`"layoutsTable`" style=`"width:100%`"><tbody><tr style=`"vertical-align:top`"><td style=`"width:100%`"><div class=`"ms-rte-layoutszone-outer`" style=`"width:100%`"><div class=`"ms-rte-layoutszone-inner`">REPLACE_ME</div></div></td></tr></tbody></table><span id=`"layoutsData`" style=`"display:none`">false,false,1</span></div>"

$contentHtml = $contentHtml.Replace("REPLACE_ME", $content);

$web = Get-SPWeb
$wiki = $web.Lists["Site Pages"]
$page = $wiki.Items | where {$_.Name -like "My Page Name*"}
$page["ows_WikiField"] = $contentHtml
share|improve this answer

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.