SharePoint file metadata updates with Set-PnPListItem and UpdateType
Updating SharePoint file metadata with Set-PnPListItem requires the correct UpdateType.
Use SystemUpdate for author and retention label changes, and UpdateOverwriteVersion when updating the editor.
When to use SystemUpdate
SystemUpdateupdates list item metadata without creating a new version or changing the modified date.- It is ideal for author changes or retention label updates.
When to use UpdateOverwriteVersion
UpdateOverwriteVersionupdates metadata and creates a new version.- It is required for editor changes because
SystemUpdatedoes not update the editor field reliably. - For migrated files, changing the editor can still create an additional version.
Example script
This sample demonstrates updating author, editor, and retention label values.
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()) {
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
}
Notes
- Changing
Authorand retention labels withSystemUpdateis the preferred approach for metadata-only updates. - Use
UpdateOverwriteVersionwhen you need theEditorfield to change. - Migrated files may still create a new version when editing the
Editorfield.