First off let me start by saying this is the first time I have posted a question here, I often visit this website and other StackExchange/Overflow sites for assistance on various projects and assignments. Hopefully I have given enough detail below for someone to help me out however please let me know if you need anything else.
I am trying to update a large number (about 6500) of publishing pages across 20-30 webs within an application that we have. I have copied existing code that I have used many times before which successfully edits pages, the only difference is that this time round I am getting the content from the file system rather than getting it from SharePoint, modifying it directly within PowerShell and putting it back in.
The changes to the PublishingPageContent field are not getting updated and revert back to it's previous value before getting checked back in and published.
ForEach ($Item in $ListItems)
{
$ItemPath = $PageDirectory + $SubWebUrl2 + "/" + $Item.Url
$ItemPath = $ItemPath -replace "/","\"
$ItemFile = $Item.File
if($ItemFile.CheckOutStatus -ne "None")
{
Write-Host "First Checkin.. " -NoNewLine
$ItemFile.CheckIn("Automatic CheckIn. (Administrator)")
}
Write-Host "Checkout.. " -NoNewLine
$ItemFile.CheckOut()
Write-Host "Updating page.. " -NoNewLine
$ItemFile.Properties.PublishingPageContent = Get-Content $ItemPath | Out-String
$ItemFile.Update()
Write-Host "Second Checkin.. " -NoNewLine
$ItemFile.CheckIn("Automatic CheckIn. (Administrator)")
}
And this is the output of a single item
Checkout.. Updating page.. Update : Exception calling "Update" with "0" argument(s): "Only String, INT, and DateTime datatypes can be used as the value in Properties."
At C:\Workspace\Step4ImportPages.ps1:48 char:19
+ $ItemFile.Update <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Second Checkin.. Publishing.. Approving.. PS C:\Workspace>
Unfortunately I am unable to provide a complete example of the content being imported, however I can say that it is just plain HTML being stored in ASPX files purely for convenience so that the file system structure replicates what is in SharePoint. The Get-Content $ItemPath command is successfully getting the HTML, here is a snippet
<H3> </H3><A name=LPTOC1></A>
<H3 class=Level2>
<DIV style="TEXT-ALIGN: right"><A name=JD_MSI247-ATTACHMENT1></A><SPAN style="FONT-WEIGHT: bold">ATTACHMENT 1</SPAN></DIV></H3>
<P> </P>