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()
Â
Per our discussion, I was able to accomplish this using the script below (testing on 2010 only). Maybe others will contribute to the thread to come up with a solution
$inputUrl = Read-Host “Enter the site URL”
$libName = Read-Host “Enter list or library name”
$web = Get-SPWeb -Identity $inputUrl
$list = $web.Lists[“$libName”]
$user = Get-SPUser -identity “SHAREPOINT\system” -web “<someSPWeb>”
foreach ($item in $list.folders)
   {
     Â
      $item[“Editor”] = $user
      $item.Update()
   }
$web.Dispose