I am trying to move some publishing pages from an old SharePoint server to a new one using powershell. When I try to update the createdDate it says the property is read only. Is there a way to change createdDate and modified date for a publishing page using powershell?
2 Answers
If you have minor versioning enabled on the list, you can try to switch it of during the update.
$list.EnableMinorVersions = $false
$list.Update()
// Update items
$aListItem["Created"] = yourNewDate
$aListItem.UpdateOverwriteVersion()
// When done, enable minor versions again
$list.EnableMinorVersions = $true
$list.Update()
-
I used your code in my powershell but the modified date is exacat the date the powershell created the page. here is my code inside the page layout: <SharePointWebControls:FormField ID="FormField2" ControlMode="Display" FieldName="Modified" DisableInputFieldLabel="true" runat="server"/>– MedesCommented Nov 28, 2013 at 9:06
Try to get list item(page) and update "Created" field:
$item["Created"] = Get-Date "5/1/2006 7:00 AM"
$item.Update()
Another option might be to create your custom field and copy data to it.
-
I used your code but it casts an exception and says something like invalid cast. my date is yyyy-mm-dd.– MedesCommented Nov 28, 2013 at 9:07