I have created a custom list named “Demo List” in which versioning is enabled.
In this blog, you will see how to get the current SharePoint Online list item version using PnP PowerShell.
- # Input Parameters
- $siteURL="https://c986.sharepoint.com/sites/dev"
- $listName="Demo List"
- # Connect to SharePoint Online site
- Connect-PnPOnline -Url $siteURL -Credentials (Get-Credential)
- # Get the list items
- $itemColl=Get-PnPListItem -List $listName
- # Get the context
- $context=Get-PnPContext
- # Loop through the items
- foreach($item in $itemColl)
- {
- # Get the item Versions
- $versionColl=$item.Versions;
- $context.Load($versionColl);
- $context.ExecuteQuery();
- #Loop through the versions
- foreach($version in $versionColl)
- {
- # Check if it is current version
- if($version.IsCurrentVersion)
- {
- Write-Host -ForegroundColor Yellow $item["Title"] " - Current Version: " $version.VersionLabel
- }
- }
- }
Open PowerShell window and run the following command.
- >cd "<folderlocation>"
folderlocation – GetCurrentVersion.ps1 file location
Run the following command
- >.\ GetCurrentVersion.ps1

Achim IsmailiPosted Jul 17, 2024, 10:58 AM
Thank you, i was really having a hard time to find out how to retrieve such a simple thing like the verison from SPO. Luckily, I found your post. ????
W EllisPosted Oct 14, 2019, 2:18 PM
Hi, thanks for your post. I seem to always get a null or empty object referring to $item.Versions (line 18) so line 19 fails. I know multiple versions of all my list items exist, also that the $item object here is valid as I can return the (non-version) data from the list item. I'm running SP 2013. Thanks.