1

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
    }
}
  • Is that you want to get all the latest version items in a document library?? – Niranjan Kulkarni Aug 8 '17 at 13:21
1

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, privacy policy and cookie policy

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