3

I have a list that has versioning turned on. Three of the fields are multi-line text boxes which have appending turned on. I want to iterate thru each item in the version history and look for changes in those 3 fields only and export to an excel spreadsheet, grouped by item number, sorted by version -descending. I need to include the current version as well.

If I can't get it broken down that much, then I'll take all versions of each item and I can filter using Excel. I would like to do this with Powershell as I am limited in how I can access the data. One of the first problems I will need to overcome is accessing our secured site (https:).

Output to look similar to this: Item# Version Field1 Field2 Field3 ModifiedDate ModifiedBy

I am a accelerated novice:-) so if you post code, please tell me where I need to replace code with my information.

I thank you for any help anyone can provide!!!! I have been stuck for months:-(

  • Good Queston! This question save my some time! – Ram Dec 21 '16 at 4:44
2

Here is the sample PowerShell code which can be used to export version history to Excel:

# ******* Variables Section ******************
#Define these variables
$WebURL="http://sharepoint.crescent.com/sites/Sales/"
$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 = "$($item.id), $($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!"

Read more: http://www.sharepointdiary.com/2014/06/sharepoint-version-history-export-to-excel.html#ixzz3IACx0Ojy

I have also developed a codeplex project for export version history. You can have a look at it here: https://exportversionhistory.codeplex.com/

  • Thanks Nadeem, but I am getting an error: Get-SPWeb : The term 'Get-SPWeb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,verify that the path is correct and try again. At C:\Users\hu5c\Desktop\ExtractVersionHistoryScript.ps1:14 char:8 + $Web = Get-SPWeb $WebURL + ~~~~~~~~~ + CategoryInfo: ObjectNotFound: (Get-SPWeb:String) [], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException I have SharePoint 2010 and I noticed on your post it said 2013 – JPHoneyPot Nov 7 '14 at 20:18
  • This may be because you are running the script in windows Powershell. You will need to load sharepoint snap in. Or else directly run the script in sharepoint Powershell – Nadeem Yousuf Nov 8 '14 at 2:03
  • How can we get the updated columns in the Version History? Like Title, Modified Time i.e Which columns are updated those? – Ram Dec 21 '16 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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