How to Enable versioning in all SharePoint Lists in Sharepoint online Powershell

Hello SharePointers,

Below is the powershell code to enable verisoning in all Sharepoint lists in SharePoint online.

$context=New-Object Microsoft.SharePoint.Client.ClientContext($url)
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$context.Load($context.Web.Lists)
$context.Load($context.Web)
$context.Load($context.Web.Webs)
$context.ExecuteQuery()

Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen
foreach( $list in $context.Web.Lists)
{
$list.EnableVersioning = $true
$list.Update()
}

Happy Sharepointing 🙂

Leave a Reply

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