How to report SharePoint list item versions in Office 365/SharePoint online?

Hello SharePointers, Below are Powershell script to get all the version history of all list items in SharePoint online/Office 365.

 $List = $Ctx.Web.Lists.GetByTitle($ListName)
        $Query = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery()
        $ListItems = $List.GetItems($Query)
        $VersionHistory = @()
Foreach ($Item in $ListItems)
write-host "Processing Item:" $ -f Yellow
#Get all versions of the list item
            $Versions = $Item.versions
            If($Versions.count -gt 0)
                #Iterate each version
                Foreach($Version in $Versions)
                    #Get the Creator object of the version
                    $CreatedBy =  $Version.createdby
                    #Send Data to object array
                    $VersionHistoryData += New-Object PSObject -Property @{
                    'Item ID' = $Item.ID
                    'Issue/Rejection Description' =  $Version.FieldValues["Issue_x002f_Rejection_x0020_Desc"]
                    'Resolution Feed'=$Version.FieldValues["Mastering_x0020_Digital_x0020_Co"]

Happy SharePointing 🙂

Leave a Reply

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