Monday, June 23, 2014

Export SharePoint List Item Version History to Excel

I wrote a PowerShell script and C# object model codes to generate SharePoint version history report in SharePoint document version history report, related to that, got a new requirement to export version history to excel.

This version history report helps to compare what data is changed, who changed the list data, etc over time.  just replace the values of WebURL, ListName variables with your Site/List values and run the script to export version history SharePoint 2013.

Here is the PowerShell script for SharePoint version history export to excel:

# ******* Variables Section ******************
#Define these variables 
$ListName ="Invoice"
$ReportFile = "D:\Invoice_VersionHistory.csv"
# *********************************************

#delete file if exists
If (Test-Path $ReportFile)
 Remove-Item $ReportFile

#Get the Web and List
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName) 

 #Check if list exists
 if($List -ne $null)
  #Get all list items
  $ItemsColl = $List.Items
  #Write Report Header
  Add-Content -Path $ReportFile -Value "Item ID, Version Lable, Created by, Created at, Title" 
  #Loop through each item
  foreach ($item in $ItemsColl) 
   #Iterate each version
      foreach($version in $item.Versions)
    #Get the version content
    $VersionData = "$($, $($version.VersionLabel), $($version.CreatedBy.User.DisplayName), $($version.Created), $($version['Title'])"
    #Write to report
    Add-Content -Path $ReportFile -Value $VersionData
Write-Host "Version history has been exported successfully!"

Please note, in Line number 25 and 36, I've added only "Title" field from the list. You may want to add additional fields as per your requirement. on running the script, all list item versions will be exported to excel (CSV format).

To export SharePoint document version history, Refer: Extract and Download all document versions

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:


  1. Fining this resource was GREAT!!! Thanks for the share. Although, I tried to get this to work on SharePoint Online and it will not. I think there may not be a command equivalent to Get-SPWeb. Is there another way to get this accomplished? Maybe via RESTful API
    What do you think? alanshieldsjr at live dot com

  2. how about SP 2010?

    1. This script works on SharePoint 2010 Also!


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...