I want to update the property vti_author
in an item in a SPDocumentLibrary, but it doesn't work. The items original vti_author
is the same even after running this script, why?
$spSite = Get-SPSite http://mySite/
$spWeb = $spSite.OpenWeb("News");
$spDocumentLibrary = $spWeb.Lists["Pages"];
$items = $spDocumentLibrary.GetItems();
foreach ($item in $items)
{
$vtiAuthor = $item.properties["vti_author"];
if ($vtiAuthor.EndsWith("sp_reader"))
{
# Check out
$file = $item.File;
$file.CheckOut();
# fails - no read only field
#$item.properties["vti_author"].ReadOnlyField = false;
$newAuthor = "DOMAIN\user";
$item.properties["vti_author"] = $newAuthor;
$item.UpdateOverwriteVersion();
# Check in
$file.CheckIn("Updated by System");
}
}