1

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 $_
    }
}
1

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.

  • Thanks Mathew. I've found solution - below short explanation. – Krzysiek Apr 19 '17 at 5:57
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.