3

I'm writing a script which gets the version of an item given the URL. However I can't seem to get the versions.

$objFile = $web.GetFile($sitecollection+/ZB/Forms/DispForm.aspx?ID=5266)
        Write-host $objFile.MinorVersion

however this doesn't seem to bring back the right results. What is the right way to get the version based on the url being dispformid=x

3

This gives you the string label of the version:

$objFile.UIVersionLabel

This gives you the Major version:

$objFile.MajorVersion

This gives you the Minor version:

$objFile.MinorVersion

Edit: The code above works with documents. The following will work with list items:

Assuming you have the id of your list item (in your example that is: "x"), you can create the $list object, get the list item and get the version of the item.

$webUrl = "http://SiteUrl";
$web = Get-SPWeb $webUrl;
$list = $web.Lists["ZB"]
$list.GetItemById(x).Versions[0].VersionLabel
| improve this answer | |

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.