Hi @Naveen Kumar B,
I would recommend you to use csom powershell to download different versions of file. Please refer to following script
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Parameters
$SiteURL = "https://Crescent.sharepoint.com"
$FileRelativeURL ="/Shared Documents/Discloser China.doc"
$DownloadPath= "C:\Temp"
#Get credentials to connect
$Cred = Get-Credential
#Setup the Context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName, $Cred.Password)
#Get the File and its versions
$File = $Ctx.Web.GetFileByServerRelativeUrl($FileRelativeURL)
$Ctx.Load($File)
$Ctx.Load($File.Versions)
$Ctx.ExecuteQuery()
If($File.Versions.Count -gt 0)
{
Foreach($Version in $File.Versions)
{
#Frame File Name for the Version
$VersionFileName = "$($DownloadPath)\$($Version.VersionLabel)_$($File.Name)"
#Get Contents of the File Version
$VersionStream = $Version.OpenBinaryStream()
$Ctx.ExecuteQuery()
#Create File version at local disk
[System.IO.FileStream] $FileStream = [System.IO.File]::Open($VersionFileName,[System.IO.FileMode]::OpenOrCreate)
$VersionStream.Value.CopyTo($FileStream)
$FileStream.Close()
Write-Host -f Green "Version $($Version.VersionLabel) Downloaded to :" $VersionFileName
}
}
Else
{
Write-host "No Versions Available for "$Item["FileRef"] -f Yellow
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.