How to Enable Versioning in Document Library in Sharepoint online Powershell?

Hello SharePointers,

Below is the powershell code to enable verisoning in all Document Libraries in a Web in SharePoint online.

$context=New-Object Microsoft.SharePoint.Client.ClientContext($url)
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)

Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen
foreach( $list in $context.Web.Lists)

if ($list.BaseType -eq “DocumentLibrary”) {
$list.EnableVersioning = $true

Happy Sharepointing 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *