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

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
add comment

1 Answer

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

As stated, this block of code updates an existing page. To create 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.

$xml = "<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>"

$xml = $xml.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"] = $xml
$page.Update()
share|improve this answer
add comment

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.