Set the major version limit for all the lists and libraries (data loss involved)

A short script that sets the major version limit for all the libraries and lists in the whole site collection or in the whole tenant. It requires SharePoint Online Management Shell and SharePoint SDK installed.

5 Star
571 times
Add to favorites
Office 365
E-mail Twitter Digg Facebook
  • Can you help me modify the script to change major versioning for all OneDrive users only?
    3 Posts | Last post September 17, 2019
    • Hi Arleta,
      I need to work it out to be able to just change the versioning of only OneDrive for Business tenant wide, instead of the entire SharePoint lists and Libraries. Is it possible? Can you please help me modify it for OneDrive for Business?
    • Hi,
      Happy to help. There you go:
    • Here is one more. This one works with all the users. The previous one works with selected users specified in a csv file.
  • Errorwhen running Script
    2 Posts | Last post November 30, 2018
      Can you help me understand and correct this error:
      Set-VersionLimit : The term 'Set-VersionLimit' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or 
      if a path was included, verify that the path is correct and try again.
    • Hi dpc41,
      The file here is an entire script, not a cmdlet you can re-use. I am guessing (please correct me if I am wrong) that after running the script, you try to use the cmdlet.
      Try instead to open the file, enter the url you are trying to connect to and run the entire script. 
  • Will this work on Sharepoint 2013?
    2 Posts | Last post September 13, 2018
    • Hi, will this code work on Sharepoint 2013? I have an on premises server and need to do this exactly.
    • Hi Paul,
      Yes, the logic is the same. What you need to do is change the authentication:
      $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $Password)
      Have a look at the following article: