Monday, June 16, 2014

Enable Versioning for All Document Libraries in SharePoint

SharePoint versioning feature tracks changes, so that you can View document or item's version history and audit/recover them if needed. 

How to enable versioning in SharePoint?
Version feature is configured at list or library level. So, to enable version history:

  • Go to your document library >> Click the Library tab on the Ribbon >> Click on Library Settings.
  • Under general Settings, click Versioning Settings link.
  • From the Versioning Settings page, choose "Create major versions". Optionally, you can set a limit on number of versions.
sharepoint 2010 enable versioning all document libraries
This enables SharePoint version history. Once versioning feature is enabled, you can select a document and click on "Version History" icon from the Ribbon to view versions created.

Enable Versioning on All Document Libraries of All Sites in SharePoint
Well activating versioning is quite simpler as shown above! But you may want to enable versioning for all document libraries from all sites in your site collection. You may have a site collection with 100's of subsites, all with document libraries loaded.

Unfortunately there is no direct way through UI to enable versioning on all libraries at Site Collection level. Here is where PowerShell scripts comes to help you to enable versioning in all libraries programmatically.

Enable versioning for all document libraries using PowerShell
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

#Get the Web
$web = Get-Spweb $webURL

#Get all lists - Exclude System lists
$ListColl = $web.lists | Where-Object  { ($_.hidden -eq $false) -and ($_.IsSiteAssetsLibrary -eq $false) -and ($_.BaseType -eq "DocumentLibrary") }

foreach($list in $ListColl)
    if ($list.EnableVersioning -eq $false) 
        #Enable Versioning Settings
        $list.EnableVersioning = $true
        $list.MajorVersionLimit = 5 #No. of versions - versioning best practices
        $list.EnableMinorVersions = $true #Applicable only to Libraries
        $list.MajorWithMinorVersionsLimit = 5 #No. of Drafts in Lists

        write-host Versioning enabled for: $list.RootFolder.URL
This script enables versioning programmatically in the entire site.

How to Enable versioning by default?
Versioning is disabled by default! There is no automatic versioning in SharePoint. There is no OOTB way to turn on versioning globally . One trick could be: using List templates - Create a Base list or library, Enable versioning, Save list as template. Any list or library created from this template have versioning turned on by default! You can also try Event Receivers -ListAdded event.

SharePoint Versioning best practices:
It is important to keep in mind that each version is basically a copy of the document or item. so if you are editing a 10 MB file for 10 times, it occupies 100 MB of disk. This could eventually affect the performance of your site. So, Its a best practice to set versioning limits.  Thankfully, SharePoint 2013 shredded storage brings the advantage of storing only the versioning delta.

Related Posts:

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...