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 ?


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 http://myspsite.com
$wiki = $web.Lists["Site Pages"]
$page = $wiki.Items | where {$_.Name -like "My Page Name*"}
$page["ows_WikiField"] = $contentHtml

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.