Ensuring Complete Sharepoint List Version Exports: Enable, Configure, Verify

Exporting SharePoint List Versions

SharePoint allows users to turn on versioning for lists and libraries to preserve a history of changes. When exporting SharePoint content, it is important to also migrate the full version history to maintain a complete record. This section covers techniques to enable, configure and export all versions of SharePoint lists.

Overview of Exporting List Version History in SharePoint

The version history of a SharePoint list contains valuable records of changes over time. It shows precisely when items were modified, who made the changes and can help identify the cause of issues. When migrating from one SharePoint environment to another, exporting the version history should be a key requirement.

SharePoint stores list version histories in the content database, recorded against individual items. An export through native SharePoint tools or APIs queries the database directly to extract all versions of list items. PowerShell also provides cmdlets to export all revisions of a list by iterating through items.

Enabling and Configuring Versioning on SharePoint Lists

Before exporting SharePoint list versions, versioning first needs to be enabled on the source list. Here are the steps to turn on versioning:

  1. Navigate to the List Settings page
  2. Under General Settings, choose Versioning Settings
  3. Set the versioning option to Create major and minor (draft) versions
  4. Define major and minor version limits e.g. Major: 50, Minor: 500
  5. Require content approval for submitted items (optional)
  6. Click OK to save versioning settings

Now as users edit items within the list, a history of changes will be preserved. The number of versions stored per item depends on the defined version limits.

Using PowerShell to Export All Versions of a List

Once versioning is enabled, PowerShell provides an effective way to export all revisions of a list. The two key requirements are:

  1. Iterate through all items in the list
  2. For each item, export the entire version history using Get-PnPListItemVersion

Here is a sample PowerShell script to export all versions of a list to a file share:

$siteURL = "https://tenant.sharepoint.com/sites/migration"
$listName = "Clients" 

Connect-PnPOnline -Url $siteURL -Credentials (Get-Credential)

$list = Get-PnPList -Identity $listName
      
$exportPath = "\\server\share\export\"

foreach($item in $list.Items) {

  Write-Host "Exporting version history for item $($item.Id)"

  $versions = Get-PnPListItemVersion -List $listName -Identity $item.Id
         
  $exportFile = $exportPath + "$($item.Id)_versions.csv" 
           
  $versions | Export-Csv -Path $exportFile -NoTypeInformation
}

This script iterates through all items in the Clients list, retrieves the full version history per item using Get-PnPListItemVersion and exports versions to individual CSV files for analysis.

Verifying Complete Exports

Once SharePoint list versions have been exported, it is important to verify that no revisions are missing from the output. Here are key techniques to validate complete version history capture.

Techniques to Validate Full List Version History is Captured

There are three main approaches to verify full version exports:

  1. Compare Total Version Count: Check the total major and minor versions exported matches source system
  2. Spot Check Major Versions: Review major versions in destination for completeness
  3. Signature Checks: Select random items, check major versions in source match destination via signatures

Comparing Version Count Between Source and Destination

A quick way to check history completeness is to compare the total version count between environments:

  1. Source – Run PowerShell: Get-PnPList | Select Title, MajorVersionLimit, MajorVersionsCount, MinorVersionLimit MinorVersionsCount
  2. Destination – Tally all main and minor versions exported per list
  3. Compare source version totals with destination per list
  4. Investigate any mismatches in totals between source and destination

Spot Checking Major Versions for Completeness

Along with total version counts, major versions can also be sampled between source and destination:

  1. In source SharePoint, review major versions for 5 random items per list
  2. In exported output, locate the major versions for the same 5 items
  3. Compare the major versions in source vs. destination to ensure consistency

If any major versions are found missing during spot checks, a full analysis is required across all items to identify gaps.

Troubleshooting Missing Versions

If list version histories show inconsistencies between source and destination environments, further troubleshooting is necessary to track down missing versions.

Common Reasons for Incomplete List Version Exports

Some common reasons list version exports may be incomplete:

  • Hit PowerShell throttling limits, preventing full site collection scans
  • Excluded system lists containing key audit history e.g. Site Collection Documents
  • Incorrect paging logic when exporting large lists >5000 items
  • Errors during export process causing version export to abort

Re-running Exports with Increased Throttling Limits

PowerShell throttling restrictions often cause version export issues. Solutions include:

  1. Use PnP PowerShell with automatic throttling handling
  2. Manually increase thresholds for operations like CSOM requests
  3. Parallelize export into smaller batches using PowerShell jobs
$RequestThreshold = 5000
$JobBatchSize = 2000

$list = Get-PnPList -Identity $listName  
$Range = 1..($list.ItemCount / $JobBatchSize)

foreach ($n in $Range){
  
  Start-Job -Name "Export$n" -ScriptBlock {
    
    $firstIndex = ($JobBatchSize * ($n - 1)) + 1        
    $lastIndex = $JobBatchSize * $n
    
    # Export subset of items 
  }
}

Get-Job | Wait-Job | Receive-Job

Leveraging the SharePoint Migration Tool for Large Exports

For very large lists, use the SharePoint Migration Tool to lift and shift the entire list structure including all versions history to the destination in a single pass.

Example PowerShell Scripts

Below find example PowerShell scripts to export SharePoint list versions.

Sample Script to Export All Versions of a List

# Parameters
$SiteUrl = "https://contoso.sharepoint.com/sites/finance"
$SourceList = "Purchase Orders"
$ExportPath = "\\server\versions\"
 
# Setup Export Folder
New-Item -Path $ExportPath -ItemType Directory
   
# Authentication 
$Cred = Get-Credential
Connect-PnPOnline -Url $SiteUrl -Credentials $Cred
  
# Iterate through items and export versions
$List = Get-PnPList -Identity $SourceList
foreach($Item in $List.Items){
 
  $Versions = Get-PnPListItemVersion -List $SourceList -Identity $Item.Id
   
  $ExportFile = $ExportPath + $Item.Id + "_versions.csv"
  $Versions | Export-Csv $ExportFile -NoTypeInformation
}

Example PowerShell Loop to Export Multiple List Histories

# Parameters
$SiteUrl = "https://contoso.sharepoint.com/sites/finance" 
$ListNames = "Purchase Orders","Invoices","Expenses"
$ExportPath = "\\server\versions\"

# Setup Export Structure 
foreach($List in $ListNames){
  New-Item -Path ($ExportPath + $List) -ItemType Directory 
}
  
# Authentication
$Cred = Get-Credential
Connect-PnPOnline -Url $SiteUrl -Credentials $Cred 

# Loop through lists
foreach($ListName in $ListNames){

  $List = Get-PnPList -Identity $ListName

  # Loop through items
  foreach($Item in $List.Items){

    $Versions = Get-PnPListItemVersion -List $ListName -Identity $Item.Id
    
    # Construct export path
    $ExportFile = $ExportPath + $ListName + "\" + $Item.Id + "_versions.csv"
    
    # Export versions 
    $Versions | Export-Csv $ExportFile -NoTypeInformation

  }

}

Recommendations

Following are key best practices around exporting SharePoint list version history.

Best Practices for Archiving Full SharePoint List Histories

  • Determine business critical lists requiring full version capture
  • Set major and minor version limits appropriately before content updates
  • Test version export early with sample content
  • Compare source and destination version totals to validate completeness
  • Use PnP PowerShell with throttling support for best performance

When to Use 3rd Party Migration Tools Over Native Exports

In certain scenarios, 3rd party migration tools can simplify exporting complete list version histories:

  • Very large lists exceeding the 5000 item pagination limit
  • Parent-child list structures requiring preservation
  • Public facing website migrations requiring additional QA
  • Coexistence of SharePoint environments during staged cutover

So for small environments, native PowerShell exports may suffice. But for large complex SharePoint ecosystems, leveraging commercial migration tools is recommended to streamline capturing full list histories.

Leave a Reply

Your email address will not be published. Required fields are marked *