Sunday, May 29, 2016

SharePoint Online: Enable Versioning on All List and Libraries using PowerShell

Requirement: Enable Versioning on all lists in SharePoint online site.

How to Enable Versioning on a List or Library in SharePoint?
To enable versioning for a list or library in SharePoint online,

  • 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 online enable version history
  • This enables SharePoint online document library versioning. Once versioning feature is enabled, you can select a document or a list item and click on "Version History" from the context menu or from the Ribbon to view versions created.
PowerShell script to enable versioning on all lists and libraries in SharePoint online:
#Load SharePoint Online 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"
##Variables for Processing
$SiteUrl = ""
$Password ="Password goes here"

    #Setup the context
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
    $Context.Credentials = $credentials
    #get the site and lists
    $web = $context.Web
    #Iterate through each list in the web
    foreach($list in $web.lists){
    if ($list.hidden -eq $false)
        #Enable versioning
        $list.EnableVersioning = $true
        $lIST.MajorVersionLimit = 50
        Write-host "Versioning has been turned ON at :"$List.title
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
This script turns on versioning in SharePoint online for all lists and libraries in the given site.

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...