The cmdlet Set-PnPListItem has different UpdateTypes: SystemUpdate, UpdateOverwriteVersion. Read more Set-PnPListItem
if($newAuthor)
{
try {
if($item.FieldValues["Author"].email.ToLower() -eq $author.ToLower()){
Set-PnPListItem -List $list `
-Identity $item.Id `
-Values @{
"Author" = $newAuthor
} `
-UpdateType SystemUpdate
Log-Message "Setting Author to: $newAuthor for: $fileUrl" "Success"
}
}
catch {
Log-Message "Failed to update author $newAuthor on $fileUrl" "Error"
}
}
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
Log-Message "Setting Editor to: $newEditor for: $fileUrl" "Success"
}
}
catch {
Log-Message "Failed to update $(if($newAuthor){'author :' & $newAuthor}else{'editor:' & $newEditor}) on $fileUrl" "Error"
}
}
if($RetentionLabel)
{
Set-PnPListItem -List $list -Identity $item.Id -Label $RetentionLabel -UpdateType SystemUpdate
}