3

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

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

for($i=$currentVersionsCount-1; $i -gt $versionstoKeep; $i--)
  {
   $SPItem.versions[$i].delete()
  }

Have a look at sharepointdiary and stackoverflow

There you'll find the necessary hints.

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.