Blog about anything related to my learnings
  • About
  • posts
bluesky
Blog about anything related to my learnings
POSTS

The cmdlet Set-PnPListItem has different UpdateTypes: SystemUpdate, UpdateOverwriteVersion. Read more Set-PnPListItem

To update author or any other properties like retention use the UpdateType SystemUpdate To update editor use the UpdateType UpdateOverwriteVersion as system update does not work.

One Caveat of updating editor of a migrated file creates another version which is annoying, otherwise works well with files created and maintained within the site itself.

 if($newAuthor)
    {
     try {
        if($item.FieldValues["Author"].email.ToLower() -eq $author.ToLower()){
        Set-PnPListItem -List $list `
                        -Identity $item.Id `
                        -Values @{
                            "Author" = $newAuthor
                        } `
                        -UpdateType SystemUpdate

          Write-host "Setting Author to: $newAuthor for: $fileUrl" 
        }
    }
    catch {
        Write-host "Failed to update author $newAuthor on $fileUrl" 
    }
  }
  if($newEditor) {
     try {
     if($item.FieldValues["Editor"].email.ToLower() -ne $newEditor.ToLower()){  
 #   "Modified" = $item.FieldValues["Modified"]
#                            "Author" = $item.FieldValues["Author"].Email
            Set-PnPListItem -List $list -Identity $item.id -Values @{
                    "Editor" = $newEditor
                } -UpdateType UpdateOverwriteVersion

            Write-host "Setting Editor to: $newEditor for: $fileUrl" 
     }   
    }
    catch {
        Write-host "Failed to update $(if($newAuthor){'author :' & $newAuthor}else{'editor:' & $newEditor}) on $fileUrl" 
    }
   }
if($RetentionLabel)
    {
        Set-PnPListItem -List $list -Identity $item.Id -Label $RetentionLabel -UpdateType SystemUpdate
    }
    © Blog about anything related to my learnings 2026
    bluesky