I am using SP2013 and trying to update the “Author” and “Editor” properties of a folder in a document library. When I run my script it appears that it updates the fields correctly, however, when I check the values again they are not actually modified. I am not sure why … Here is my existing script.
$web = Get-SPWeb “http://mytestbox/sites/tech/”
$site=$web
$list = $web.Lists[“Reports”]
foreach ($item in $list.Folders)
{
$itemauthor = $item[“Author”]
$itemeditor = $item[“Editor”]
$itemmod = $item.Properties.vti_modifiedby
write-host “Author is: ” $itemauthor
write-host “Editor is: ” $itemeditor
write-host “Modified By is: ” $itemmod
if($itemauthor -eq “1;#domainxyz\doveal”)
{
$itemauthor = “1;#sharepoint\system”
Write-Host “The folder author is ” $itemauthor
$item.Update()
Write-Host “The folder author is updated”
}
if($itemeditor -eq “1;#domainxyz\doveal”)
{
$itemeditor = “1;#sharepoint\system”
Write-Host “The folder editor is ” $itemeditor
$item.Update()
Write-Host “The folder editor is updated”
}
if($itemmod -eq “i:0#.w|domainxyz\doveal”)
{
$itemmod = “i:0#.w|sharepoint\system”
Write-Host “The folder modified by is ” $itemmod
$item.Update()
Write-Host “The folder modified by is updated”
}
write-host “Author is: ” $itemauthor
write-host “Editor is: ” $itemeditor
write-host “Modified By is: ” $itemmod
}
$site.Update()
$site.Dispose()
Â
When running your code, Jason, I am getting the following error:
Exception calling “Update” with “0” argument(s): “Invalid data has been used to update the list item. The field you are trying to update may be read only.”
Any suggestions?