I want to delete old version (0.5) and keep latest version (0.10) from a library.

How can I achieve it using PowerShell Script.

If(0.5 < 0.10)

 Remove version with 0.5 and keep 0.10
 But I doubt system takes 0.5 as 0.50 then the logic is not correct.


How can I get latest/current version number and delete older version?

2 Answers 2


You will have to use array index within the versions list like

for($i=$currentVersionsCount-1; $i -gt $versionstoKeep; $i--)

Have a look at sharepointdiary and stackoverflow

There you'll find the necessary hints.


I guess it is already to late for your project, but if someone has the same issue, you can use the tool DMS-Shuttle. It does exactly. Read that article: https://dms-shuttle.com/documentation/delete-version-history-in-sharepoint-online-office-365/ I am working for the vendor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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