a way to retrieve metadata of a previous version of a file? (using CSOM in PowerShell in SPO)

Silver Contributor

I am using CSOM in PowerShell, querying SharePoint Online, but in general, I am looking for a way to retrieve what a specific column/value was on previous versions of a document programmatically.

 

I can get to the actual previous versions this way, and some basic version values, like url, created date, etc, but can't seem to find anything about the actual custom column values.

 

$Versions = $item.File.Versions
$clientContext.Load($Versions)
$clientContext.ExecuteQuery()

foreach($Version in $Versions){
   Write-Host $Version.VersionLabel
   Write-Host $Version.Url
   Write-Host $Version.Created
}

9 Replies
Meta data will not be available for previous versions.
Ey Brent,
The metadata should be in the Properties member of the SPFileVersion class: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfileversion_members.aspx Don't know for sure If you will be able to get the data you want

@Brent Ellis have a look at this update https://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365-august-2017 and especially those classes:

 

public property Microsoft.SharePoint.Client.ListItem.Versions

public class Microsoft.SharePoint.Client.ListItemVersion

public class Microsoft.SharePoint.Client.ListItemVersionCollection

 

If they do not work for you, there is a way to do it from the _vti_bin/Lists.asmx service.

More info here: http://blog.velingeorgiev.pro/how-get-list-item-field-versions-data-sharepoint-online. It is not first class solution, but getting version metadata was not available in CSOM few months ago, I do know know if the august 2017 update will offer more on versions metadata (haven't tested it yet). Let me know if works, thanks!

Hi @Brent Ellis, have a look at the CSOM August 2017 release, especially those classes:

  • public property Microsoft.SharePoint.Client.ListItem.Versions
  • public class Microsoft.SharePoint.Client.ListItemVersion
  • public class Microsoft.SharePoint.Client.ListItemVersionCollection

 

I  have not seen what is in these classes yet, if they do not work for you then you can assess the List Item Version Metatdata item from the _vti_bin/Lists.asmx service. More info here: How to get list item field versions data in SharePoint Online. It is not ideal solution ad would be great if the august update offers that, but it is the only alternative I found so far.

Appreciate all the responses, I managed to figure it out a while back (but didn't update this thread), but I believe I used this CSOM route you referenced to do it.

Hi Brent,

 

Can you pls share your solution which you implemented. Thanks!

 

Dinesh

That last link now takes the user to a malware site. I know this post is from 5 years ago, but still...

@Velin Georgiev That last link now takes the user to a malware site. I know this post is from 5 years ago, but still...