SharePoint Online Versioning RRS feed

  • Question

  • Hi all,

    Our company stores documents in a SharePoint site, we have to upload mp4 videos to share to externals, a few weeks ago i noticed that a mp4 file had been edited a few times hence creating different versions of the file so a 200mb file jumped up very quickly, I believe alot of our video files have numerous versions now, is there a way to remove the versions with Powershell?

    Thanks in advance

    Thursday, July 9, 2020 4:00 PM

All replies

  • Below Powershell script will disable versioning for single library, if you want to do it for all libraries the below article have script for that requirement as well:

    #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"
    Function Disable-SPOVersioning()
            [Parameter(Mandatory=$true)] [string] $SiteURL,
            [Parameter(Mandatory=$true)] [string] $ListName
        Try {
            #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 List
            $List = $Ctx.Web.Lists.GetByTitle($ListName)
            #sharepoint online powershell disable versioning
            $List.EnableVersioning = $False
            Write-host -f Green "Versioning has been turned OFF at $ListName"
        Catch {
            write-host -f Red "Error:" $_.Exception.Message
    #Set Parameters
    $ListName="Migration Documents"
    #Call the function 
    Disable-SPOVersioning -SiteURL $SiteURL -ListName $ListName


    Thanks & Regards,

    sharath aluri

    Thursday, July 9, 2020 4:46 PM
  • Hi agentdogit12345,

    Disabling versioning as suggested by Sharath is one approach. However, there are probably use cases where versioning is required.

    It is a serious problem. At one of our customers a small team was simultaneously working on a chunky PPTX file. We ended up making 200 versions of 15 MB each. Users are often not aware how many versions they generate.

    Another approach is to use tools / scripts to find the hotspots. There are PowerShell scripts but also browser-based Apps that can find the hotspots and selectively purge versions. e.g.

    Friday, July 10, 2020 9:35 AM
  • Thank you for that, it did the trick, I have run a script to reduce versions down to 2 on a certain list folder, will that take a while to work through the site as we have a lot of files in this SharePoint site

    Thanks again Sharath

    Friday, July 10, 2020 9:46 AM
  • Thanks Paul I will look into this, I just saw a file that has been edited so many times, the size is 7.2mb but with all the versions it is actually 3GB
    Friday, July 10, 2020 11:02 AM
  • I have managed to reduce versions down to 5 now but I wanted to remove the versions with powershell but getting this error now

    Get-PnPListItem : The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.

    We have like 20,000 files  is there a way round this?

    Friday, July 10, 2020 4:26 PM