1

On our libraries we set versioning settings = create major versions and keep 50 of them. We'd like to remove only the "Keep the following number of major versions" setting on all libraries. Because there are many libs we'd like to execute a PowerShell script. But

  • the major setting checkbox itself seems to be no property, we just can set

    $list.EnableVersioning = $true
    
    $list.EnableMinorVersions = $false
    
  • we cannot just set the number of major versions to 0 (= invalid value)

  • we cannot just reverse EnableVersioning (set it to false, update and afterwards set it to true again => the former number of major versions reappear)

So how to get rid of the number of major versions limit without changing the rest of the versioning settings using PowerShell?

1 Answer 1

3

Here is my test script to clean "Keep the following number of major versions" and "Keep drafts for the following number of major versions" options if enabled "Create major and minor (draft) versions".

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
#Get the web 
$SourceWebURL = "http://sp:12001/"
$ListName="MyDoc"
$Spweb = Get-SPWeb $SourceWebURL
$SPList = $Spweb.Lists.TryGetList($ListName)
$SPList.MajorVersionLimit=0;
$SPList.MajorWithMinorVersionsLimit=0;
$SPList.Update();
write-host "Done"
1
  • 1
    ok, it works, thanks a lot. I didn't except that setting to zero would work because it's not accepted in GUI
    – Celophysis
    Dec 14, 2017 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.