2

I want to fetch latest or current version of an item in a document library.

How can I achieve this using PowerShell Scripting?

Is $version.VersionLabel value of version number?

But I don't want to loop through $item.Versions, I just want the current or latest version of an item.

Thanks in advance.`

foreach($item in $ItemCollection)
{
    foreach($version in $item.Versions)
    {
    Write-Host "Documen Library:" $list.Title "-" "Document:" $item.Title $version.VersionLabel
    }
}
1
  • Is that you want to get all the latest version items in a document library?? Commented Aug 8, 2017 at 13:21

1 Answer 1

2

The latest version can be found at first index of $item.Versions. Try following

foreach($item in $ItemCollection)
  {
      Write-Host "Documen Library:" $list.Title "-" "Document:" $item.Title $item.Versions[0].VersionLabel
  }

Current/Latest Version

$item.Versions[0].VersionLabel

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.