So I am trying to extract version history from a document library in Powershell. I have found the commands/scripts to do this. However I cannot seem to get the comments. From my script I can get modified date ($Ver.Created), user ($Ver.CreatedBy), and version ($Ver.VersionLabel) where $Ver is derived from the foreachloop that loops through Items in a Document Library.

I checked Microsoft's Object members site and found 'Comments', but this has produced nothing. I have tried "Comment", "CheckedInComments", "CheckedInComment".

At this point I am trying to find the script that will extract all member names so I can see which one it is. And yes I do have comments there.

The internet has helped. It helped me make the script I have so far but it looks like all the examples I have found do not talk about the comments at all.

----Update----- I found the member, altering the script to look like this:

$Ver["Check In Comment"]

Instead of this:


I get results but its only the last comment of the latest version. The object gets me different data ("VersionLabel") except for the comments

foreach ($item in $ItemsColl)  
    if ($item.Name -eq $fileName)
    Write-Output "File Name " $item.Name | Out-File $logFile -append
        foreach($Ver in $item.Versions)
            Write-Output "Version Label" $Ver.VersionLabel " Created " $Ver.Created " Modified by " $Ver.CreatedBy.User.DisplayName | Out-File $logFile -append
            Write-Output "Check In Comment " $Ver["Check In Comment"] | Out-File $logFile -append

1 Answer 1


You are iterating through the version history for the list item itself but it sounds like what you want is the information for the file versions which is a little deeper. There is a .File property off of the SPListItem that returns an SPFile object. That object has a Versions collection that you need to iterate through to get the information you want.

  • That makes sense ... Will work on that.
    – fraygos
    Aug 7, 2012 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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