I'm trying to programatically edit a page that is being transitioned from server #1 to server #2, #3... etc.

I tried including the page inside a module, and later on opening it and extracting its text... I was mortified to realize that all the content in the file, inside of the tags, had been stripped out.

$enc = New-Object system.text.asciiencoding
$result=$enc.GetString($bytes) # Only returns a little

I have not been able to find all of that content (headings and several list web parts). I've gotten close to finding it when I discovered that an SPFile for the page kinda had some content...


This contains several divs, a table, and all of the headers... and couple of divs that contain GUIDs in their .id and .class attributes that point towards the list views that were in the original file...

But alas, the rest of the contents of these files are nowhere else to be found.

I have no idea where I'm looking for the contents of the file here. I'm at a total loss.


The content is stored in the content database.

You can access them as if you were accessing list item columns (try the 'PublishingPageContent' column) or, in the case of inserted Web Parts, you can use the SPLimitedWebPartManager class

You do this with the SPListItem object and not the SPFile object.

  • Is there a way to just return the contents of what's going into the layout itself, as a single bit of text (such as how SharePoint Designer allows me to traverse the entire file)? – user22303 Oct 16 '14 at 21:53
  • the 'PublishingPageContent' has the HTML for the Content area of the page. Unless you added other Html fields to the page layout that should have most of it. I looked in to something similar a while back but was unable to get the whole page content to move to another server. To do that you might want to look into the Content Deployment API – Choggo Oct 16 '14 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy