Enable list and library Versions using PowerShell Script except the hidden lists

Advertisement
Using this script we can Enable Version with Major Version Limit under site content(Only visible list, not hidden list) all list and library

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$web = get-spsite "https://dotnetsharepoint.com/"

# For All Sub Sites
foreach ($spWeb in $web.AllWebs)
{
$lists = $spWeb.lists
foreach ($list in $lists)
{
#Only visible list under site contents
if(!$list.Hidden)
{
    # Enabling version   
    if($list.EnableVersioning -eq $false)
    {  
         write-host $list.title "Version Enabled for this site"
         $list.Enableversioning = $true
         $List.MajorVersionLimit = 5
         $list.update()
    }
}

}

}
Advertisements
SHARE

Lakshmi Tulasi Jasti

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a comment