I have followed the following link to successfully export SharePoint list data to a csv format with Version History intact.

How can we read version history of document library and update particular version (few fileds) data in Sqlserver database?

However, I am hitting an issue with some colmns that are Multi line text fields with Rich Text Formats. This upsets the format of the CSV file with carriage returns and whitespace upsetting the alignment.

Any suggestions on how to get a neatly formatted CSV file that can achieve the above please?

Thanks in advance

1 Answer 1


You could try the below scripts:

$ListName ="ct1"
$ReportFile = "C:\test.csv"
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName)

 #Check if list exists
 if($List -ne $null)
  #Get all list items
  $ItemsColl = $List.Items

  $ListItemCollection = @()

  #Loop through each item
  foreach ($item in $ItemsColl)
   #Iterate each version
      foreach($version in $item.Versions)
   $ExportItem = New-Object PSObject
   $ExportItem | Add-Member -MemberType NoteProperty -name "Item ID" -value $item.id
   $ExportItem | Add-Member -MemberType NoteProperty -Name "Version Lable" -value $version.VersionLabel
   $ExportItem | Add-Member -MemberType NoteProperty -name "Created by" -value $version.CreatedBy.User.DisplayName
   $ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $version['Title']
   $ExportItem | Add-Member -MemberType NoteProperty -name "Multi" -value $version['Multi']
   $ListItemCollection += $ExportItem

$ListItemCollection | Export-CSV  $ReportFile -NoTypeInformation 
Write-Host "Version history has been exported successfully!"

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.