How to get Version history of a Sharepoint list /Library using Powershell in SharePoint 2010/2013 /Online?

Hello Sharepointers,

In this blog, we will try to see the list of steps involved in getting version history of a sharepoint list in a sharepoint site using Powershell.

$WebURL=”Site URL”

$ListName =”List Name”

$ReportFile = “C:\Results.csv”

$List = $web.Lists.TryGetList($ListName)

#Check if list exists

if($List -ne $null)

{

#Get all list items

$Items = $List.Items

#Write Report Header

Add-Content -Path $ReportFile -Value “Item ID, Version Lable, Created by, Title”

#Loop through each item

foreach ($item in $Items)

{

foreach($version in $item.Versions)

{

$output= “$($item.id), $($version.VersionLabel), $($version.CreatedBy.User.DisplayName),  $($version[‘Title’])”

#Write to report

Add-Content -Path $ReportFile -Value $output

}

}

}

Write-Host “Version history has been shown successfully!”

Happy Sharepointing Folks 🙂

Leave a Reply

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