Question

I can't delete version range e.g. from VersionLabel=200 to VersionLabel=220. When I run powershell command it just deletes every second version (220, 222, 224 etc). Anyone know why it can't delete every version I want to delete?

...setting $versionsToDelete and

foreach($versionToDelete in $versionsToDelete){
    try {                
        Write-Host "Version $($versionToDelete.VersionLabel) created $($versionToDelete.Created) by $($versionToDelete.CreatedBy) will be removed"
        $versionToDelete.delete()
    } catch {
        Write-Error $_
    }
}
Was it helpful?

Solution 2

Solved. The problem is that SharePoint after removing version e.g. version 220 moves all versions after version 220 and recalculates VersionId. After remove version I have to read again item and item's versions and remove next version e.g. 221.

OTHER TIPS

you can try following approach may be it help

  1. Goto Version settings of the list

    and select version type Create major and minor (draft) versions Example: 1.0, 1.1, 1.2, 2.0

  2. Set Require Check Out Yes

Go to the list item -> checkin the document and override the document checkin. Then try to delete the document and rollback you changes.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top