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

%3CLINGO-SUB%20id%3D%22lingo-sub-24047%22%20slang%3D%22en-US%22%3Ea%20way%20to%20retrieve%20metadata%20of%20a%20previous%20version%20of%20a%20file%3F%20(using%20CSOM%20in%20PowerShell%20in%20SPO)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-24047%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20CSOM%20in%20PowerShell%2C%20querying%20SharePoint%20Online%2C%20but%20in%20general%2C%20I%20am%20looking%20for%20a%20way%20to%20retrieve%20what%20a%20specific%20column%2Fvalue%20was%20on%20previous%20versions%20of%20a%20document%20programmatically.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20get%20to%20the%20actual%20previous%20versions%20this%20way%2C%20and%20some%20basic%20version%20values%2C%20like%20url%2C%20created%20date%2C%20etc%2C%20but%20can't%20seem%20to%20find%20anything%20about%20the%20actual%20custom%20column%20values.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24Versions%20%3D%20%24item.File.Versions%3CBR%20%2F%3E%24clientContext.Load(%24Versions)%3CBR%20%2F%3E%24clientContext.ExecuteQuery()%3C%2FP%3E%3CP%3Eforeach(%24Version%20in%20%24Versions)%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3BWrite-Host%20%24Version.VersionLabel%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3BWrite-Host%20%24Version.Url%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3BWrite-Host%20%24Version.Created%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-128691%22%20slang%3D%22en-US%22%3ERe%3A%20a%20way%20to%20retrieve%20metadata%20of%20a%20previous%20version%20of%20a%20file%3F%20(using%20CSOM%20in%20PowerShell%20in%20SPO)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-128691%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Brent%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20pls%20share%20your%20solution%20which%20you%20implemented.%20Thanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDinesh%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103497%22%20slang%3D%22en-US%22%3ERe%3A%20a%20way%20to%20retrieve%20metadata%20of%20a%20previous%20version%20of%20a%20file%3F%20(using%20CSOM%20in%20PowerShell%20in%20SPO)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103497%22%20slang%3D%22en-US%22%3EAppreciate%20all%20the%20responses%2C%20I%20managed%20to%20figure%20it%20out%20a%20while%20back%20(but%20didn't%20update%20this%20thread)%2C%20but%20I%20believe%20I%20used%20this%20CSOM%20route%20you%20referenced%20to%20do%20it.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103021%22%20slang%3D%22en-US%22%3ERe%3A%20a%20way%20to%20retrieve%20metadata%20of%20a%20previous%20version%20of%20a%20file%3F%20(using%20CSOM%20in%20PowerShell%20in%20SPO)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103021%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F637%22%20target%3D%22_blank%22%3E%40Brent%20Ellis%3C%2FA%3E%2C%26nbsp%3Bhave%20a%20look%20at%20the%20%3CA%20href%3D%22https%3A%2F%2Fdev.office.com%2Fblogs%2Fnew-sharepoint-csom-version-released-for-Office-365-august-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3ECSOM%20August%202017%3C%2FA%3E%20release%2C%20especially%20those%20classes%3A%3C%2FP%3E%3CUL%3E%3CLI%3Epublic%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eproperty%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EMicrosoft.SharePoint.Client.ListItem.Versions%3C%2FLI%3E%3CLI%3Epublic%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eclass%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EMicrosoft.SharePoint.Client.ListItemVersion%3C%2FLI%3E%3CLI%3Epublic%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eclass%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EMicrosoft.SharePoint.Client.ListItemVersionCollection%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20%26nbsp%3Bhave%20not%20seen%20what%20is%20in%20these%20classes%20yet%2C%20if%20they%20do%20not%20work%20for%20you%20then%20you%20can%20assess%20the%20List%20Item%20Version%20Metatdata%20item%20from%20the%20_vti_bin%2FLists.asmx%20service.%20More%20info%20here%3A%20%3CA%20href%3D%22http%3A%2F%2Fblog.velingeorgiev.pro%2Fhow-get-list-item-field-versions-data-sharepoint-online%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHow%20to%20get%20list%20item%20field%20versions%20data%20in%20SharePoint%20Online%3C%2FA%3E.%20It%20is%20not%20ideal%20solution%20ad%20would%20be%20great%20if%20the%20august%20update%20offers%20that%2C%20but%20it%20is%20the%20only%20alternative%20I%20found%20so%20far.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103008%22%20slang%3D%22en-US%22%3ERE%3A%20a%20way%20to%20retrieve%20metadata%20of%20a%20previous%20version%20of%20a%20file%3F%20(using%20CSOM%20in%20PowerShell%20in%20SPO)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103008%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F637%22%20target%3D%22_blank%22%3E%40Brent%20Ellis%3C%2FA%3E%26nbsp%3Bhave%20a%20look%20at%20this%20update%20%3CA%20href%3D%22https%3A%2F%2Fdev.office.com%2Fblogs%2Fnew-sharepoint-csom-version-released-for-Office-365-august-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.office.com%2Fblogs%2Fnew-sharepoint-csom-version-released-for-Office-365-august-2017%3C%2FA%3E%20and%20especially%20those%20classes%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Epublic%20property%20Microsoft.SharePoint.Client.ListItem.Versions%3C%2FP%3E%3CP%3Epublic%20class%20Microsoft.SharePoint.Client.ListItemVersion%3C%2FP%3E%3CP%3Epublic%20class%20Microsoft.SharePoint.Client.ListItemVersionCollection%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20they%20do%20not%20work%20for%20you%2C%20there%20is%20a%20way%20to%20do%20it%20from%20the%20_vti_bin%2FLists.asmx%20service.%3C%2FP%3E%3CP%3EMore%20info%20here%3A%20%3CA%20href%3D%22http%3A%2F%2Fblog.velingeorgiev.pro%2Fhow-get-list-item-field-versions-data-sharepoint-online%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fblog.velingeorgiev.pro%2Fhow-get-list-item-field-versions-data-sharepoint-online%3C%2FA%3E.%20It%20is%20not%20first%20class%20solution%2C%20but%20getting%20version%20metadata%20was%20not%20available%20in%20CSOM%20few%20months%20ago%2C%20I%20do%20know%20know%20if%20the%20august%202017%20update%20will%20offer%20more%20on%20versions%20metadata%20(haven't%20tested%20it%20yet).%20Let%20me%20know%20if%20works%2C%20thanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-102813%22%20slang%3D%22en-US%22%3ERe%3A%20a%20way%20to%20retrieve%20metadata%20of%20a%20previous%20version%20of%20a%20file%3F%20(using%20CSOM%20in%20PowerShell%20in%20SPO)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-102813%22%20slang%3D%22en-US%22%3E%3CP%3EThat%20would%20be%20for%20SSOM%2C%20not%20CSOM.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-24872%22%20slang%3D%22en-US%22%3ERe%3A%20a%20way%20to%20retrieve%20metadata%20of%20a%20previous%20version%20of%20a%20file%3F%20(using%20CSOM%20in%20PowerShell%20in%20SPO)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-24872%22%20slang%3D%22en-US%22%3EEy%20Brent%2C%3CBR%20%2F%3EThe%20metadata%20should%20be%20in%20the%20Properties%20member%20of%20the%20SPFileVersion%20class%3A%20%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fmicrosoft.sharepoint.spfileversion_members.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fmicrosoft.sharepoint.spfileversion_members.aspx%3C%2FA%3E%20Don't%20know%20for%20sure%20If%20you%20will%20be%20able%20to%20get%20the%20data%20you%20want%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-24063%22%20slang%3D%22en-US%22%3ERe%3A%20a%20way%20to%20retrieve%20metadata%20of%20a%20previous%20version%20of%20a%20file%3F%20(using%20CSOM%20in%20PowerShell%20in%20SPO)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-24063%22%20slang%3D%22en-US%22%3EMeta%20data%20will%20not%20be%20available%20for%20previous%20versions.%3C%2FLINGO-BODY%3E
Highlighted
Valued 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
}

7 Replies
Highlighted
Meta data will not be available for previous versions.
Highlighted
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
Highlighted
Highlighted

@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!

Highlighted

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.

Highlighted
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.
Highlighted

Hi Brent,

 

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

 

Dinesh