none
Automatically enable versioning on all document libraries?

    Question

  • Is there a way to enable versioning on all existing document libaries or any new sites that get created?      The default is no versioning whenever a new doc library gets created.     thanks
    Monday, August 15, 2011 12:31 PM

Answers

  • There is no OOTB feature to do this but below mentioned powershell script will enable it on all existing sites:

    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
    $siteURL = $args[0]
    $site = Get-SPSite($siteURL)
    foreach($web in $site.AllWebs) {
     Write-Host "Inspecting " $web.Title
     foreach ($list in $web.Lists) {
     if($list.BaseType -eq "DocumentLibrary") {
     Write-Host "Versioning enabled: " $list.EnableVersioning
     $host.UI.WriteLine()
     Write-Host "MinorVersioning Enabled: " $list.EnableMinorVersions
     $host.UI.WriteLine()
     Write-Host "EnableModeration: " $list.EnableModeration
     $host.UI.WriteLine()
     Write-Host "Major Versions: " $list.MajorVersionLimit
     $host.UI.WriteLine()
     Write-Host "Minor Versions: " $list.MajorWithMinorVersionsLimit
     $host.UI.WriteLine()
     $list.EnableVersioning = $true
     $list.EnableMinorVersions = $true
     $list.MajorVersionLimit = 2
     $list.MajorWithMinorVersionsLimit = 5
     $list.Update()
     Write-Host $list.Title " is updated with MajorVersionLimit 2 and MajorwithMinorVersionsLimit = 5"
     }
     }
    }
    
    

    Plus check this blog , you can use similar code on SP2010

    http://mkdot.net/blogs/boban/archive/2008/07/22/turn-on-versioning-on-sharepoint-document-library.aspx
     


    Amrita Talreja
    • Proposed as answer by Amrita Talreja Monday, August 15, 2011 12:54 PM
    • Unproposed as answer by Seven M Friday, August 26, 2011 3:34 AM
    • Marked as answer by Seven M Friday, August 26, 2011 3:35 AM
    Monday, August 15, 2011 12:54 PM
  • This thread contains the same question and probably answers it for you:

    http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/ae67e3a6-d2a4-4253-ad86-4a5ebca313ae/

    In short: No, but there are ways you could achieve it using custom code or Powershell.


    SharePoint Solutions Architect - http://blog.morg.nl
    • Marked as answer by Seven M Friday, August 26, 2011 3:34 AM
    Monday, August 15, 2011 12:51 PM

All replies

  • This thread contains the same question and probably answers it for you:

    http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/ae67e3a6-d2a4-4253-ad86-4a5ebca313ae/

    In short: No, but there are ways you could achieve it using custom code or Powershell.


    SharePoint Solutions Architect - http://blog.morg.nl
    • Marked as answer by Seven M Friday, August 26, 2011 3:34 AM
    Monday, August 15, 2011 12:51 PM
  • There is no OOTB feature to do this but below mentioned powershell script will enable it on all existing sites:

    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
    $siteURL = $args[0]
    $site = Get-SPSite($siteURL)
    foreach($web in $site.AllWebs) {
     Write-Host "Inspecting " $web.Title
     foreach ($list in $web.Lists) {
     if($list.BaseType -eq "DocumentLibrary") {
     Write-Host "Versioning enabled: " $list.EnableVersioning
     $host.UI.WriteLine()
     Write-Host "MinorVersioning Enabled: " $list.EnableMinorVersions
     $host.UI.WriteLine()
     Write-Host "EnableModeration: " $list.EnableModeration
     $host.UI.WriteLine()
     Write-Host "Major Versions: " $list.MajorVersionLimit
     $host.UI.WriteLine()
     Write-Host "Minor Versions: " $list.MajorWithMinorVersionsLimit
     $host.UI.WriteLine()
     $list.EnableVersioning = $true
     $list.EnableMinorVersions = $true
     $list.MajorVersionLimit = 2
     $list.MajorWithMinorVersionsLimit = 5
     $list.Update()
     Write-Host $list.Title " is updated with MajorVersionLimit 2 and MajorwithMinorVersionsLimit = 5"
     }
     }
    }
    
    

    Plus check this blog , you can use similar code on SP2010

    http://mkdot.net/blogs/boban/archive/2008/07/22/turn-on-versioning-on-sharepoint-document-library.aspx
     


    Amrita Talreja
    • Proposed as answer by Amrita Talreja Monday, August 15, 2011 12:54 PM
    • Unproposed as answer by Seven M Friday, August 26, 2011 3:34 AM
    • Marked as answer by Seven M Friday, August 26, 2011 3:35 AM
    Monday, August 15, 2011 12:54 PM
  • Amrita Talreja,

    Please don't propose your own post.

    Regards,

    Seven 

    Friday, August 26, 2011 3:36 AM
  • Hi Amrita - thank you for this answer. 

    Any chance you have this code for SharePoint 365 (2016)?

    My IT support team tried running it in our instance and we got several errors. 

    Thanks so much for your help! 

    Guillermo 

    Wednesday, November 30, 2016 11:43 PM