I'm want to move documents between site collections retaining their version history(Major and Minor versions). I used this blog http://bit.ly/NPftRE as a reference and was able to move documents with versions retaining the modified date and modified by for minor versions. But for Major version document it shows the modified date as current date. Below is the partial view of the powershell script.
if ($isMajorVersion)
{
if ($fileDestination.CheckOutType -eq "Online")
{
$newItem = $fileDestination.Item
$newItem["Modified"] = $dateModified.ToLocalTime()
$newItem.UpdateOverwriteVersion()
$fileDestination.CheckIn($checkInComment)
$fileDestination.Publish($checkInComment)
}
}
else
{
$newItem = $fileDestination.Item
$newItem["Created"] = $dateCreated
$newItem["Modified"] = $dateModified
$newItem.UpdateOverwriteVersion();
if ($fileDestination.CheckOutType -eq "Online")
{
$fileDestination.CheckIn($checkInComment)
}
}
I used the UpdateOverwriteVersion before publishing the document but after the call to Publish() method the modified date (on version history view) changes to current date.
Any suggestions?