posts
The cmdlet Set-PnPListItem has different UpdateTypes: SystemUpdate, UpdateOverwriteVersion. Read more Set-PnPListItem
To update author 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.
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.
posts
Auto Trimming version - Minor Major # ===== Settings ===== $clientId = "xxxxxxxx" $dateTime = Get-Date -Format "yyyy-MM-dd-HH-mm-ss" $CertPath = Read-Host "Please enter Certificate (.PFX) Path" $CertPassword = Read-Host "Please enter Certificate Password" -AsSecureString $Org = "contoso.onmicrosoft.com" $fileUrl = "https://contoso.sharepoint.com/sites/test/Documents/test_resh_retentionlabel.docx" $invocation = Get-Variable -Name MyInvocation -ValueOnly $directoryPath = Split-Path $invocation.MyCommand.Path function Get-LibraryNameFromFileUrl { param([string]$fileUrl, [string]$siteUrl) # Remove base site URL $relative = $fileUrl.Replace($siteUrl, "") # Trim leading "/" if ($relative.StartsWith("/")) { $relative = $relative.
posts
I have been doing some testing: major versions are trimmed if exceeding the 500 versions, minor versions gets incremented up to 511 and beyond end user needs to publish as major. Auto trimming works with files without retention labels trimming the minor/major version bypassing the recycle bin.
However with files with retention labels are behaving similarly to retention policy and none of the major or minor versions get deleted, version are expired only to be extended further for more days after 1-2 days instead being deleted.