How to enable verionsioning in SharePoint site through powershell script.

 Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

$site = Get-SPSite($siteURL)
foreach($web in $site.AllWebs) {
    Write-Host "Inspecting " $web.Title
    foreach ($list in $web.Lists) {
        if($list.BaseType -eq "DocumentLibrary")
 # if($list.BaseType -eq "GenericList")  for List calenar task.
      {
            Write-Host "Versioning enabled: " $list.EnableVersioning
            Write-Host "MinorVersioning Enabled: " $list.EnableMinorVersions
            Write-Host "EnableModeration: " $list.EnableModeration
            Write-Host "Major Versions: " $list.MajorVersionLimit
            Write-Host "Minor Versions: " $list.MajorWithMinorVersionsLimit
            $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"
        }
    }
}

No comments:

Post a Comment

SPFX - HTTPClient - Curd Operations - SharePoint list.

  Create solution in the name of SpfxCrud. ISpfxCrudProps.ts export interface ISpfxCrudProps {   description : string ;     context : an...