I'm using OneDrive (office 365 account) as a cloud backup, and I got a problem with the versioning system as for big files (outlook .ost and .pst mainly) it keeps generating new versions for the file with each synchronization thus reaching easily the storage account limit.
I wasn't able to find a way to limit the (Major) versioning number under 100 (do you have any suggestion other than Microsoft article)
Anyway, I came across this wonderful solution/code to control the number of versions of a file/folder and I adapted it for my scenario.
It works absolutely fine, BUT when the file is big (let say > 1GB), ALWAYS get this error trying to get its versions.
Operation is not valid due to the current state of the object.
No matter how I access the file versions it gets an error. I tried several approaches:
Get-PnPProperty -ClientObject $File -Property Versions
- Using context...
$Ctx = Get-PnPContext $Ctx.RequestTimeOut = -1 $Ctx.Load($File.Versions) $Ctx.ExecuteQuery()
But I can't get it right. I'm currently using PnP PowerShell .NET Core version, but the same happens with previous versions.
Note: I can still manage/delete the versions by web interface, but not by code