문제

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

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top