Getting SharePoint List Version Setting for all lists

I was working at a client doing a health assessment and during the assessment we talked about problems with users being able to turn on versioning. That being that each time a modification is made it keeps a copy of that file and if versioning is turned on then this can drastically increase your content database sizes pretty quickly. I setup this script to be able to help identify what the settings are. This script could be modified to enforce a policy on what the limits should be as well.

Here is the powershell script or you can download it from here: CheckWebAppListVersioningSettings

 

# Powershell Script written to get the lists that have versioning enabled and if so the settings on those lists.
# Written by 
# Ryan Schouten
# http://www.sharepointknight.com
# Senior Consultant
# ZAACT
# http://www.zaact.com

$siteURL="http://UrlToTheWebApplicationThatYouWantToCheck"
$site=Get-SPSite $siteURL
$webApp = $site.WebApplication
foreach($spsite in $webApp.Sites)
{
	foreach($web in $spsite.AllWebs)
	{
		$url = $web.Url
		Write-Output "Web Url: $url"
		foreach($list in $web.Lists)
		{
			if($list.EnableVersioning -eq $True)
			{
				$listTitle = $list.Title
				$output = "    Versioning enabled on list $listTitle. Major version limit:"

				if($list.MajorVersionLimit -eq 0)
				{
					$output = "{0} {1}" -f $output,"NO LIMIT"
				}
				else
				{
					$output = "{0} {1}" -f $output,$list.MajorVersionLimit
				}
				$output = "{0}. Minor Versions enabled: {1}" -f $output,$list.EnableMinorVersions
				if($list.EnableMinorVersions -eq $True)
				{
					if($list.MajorWithMinorVersionsLimit -eq 0)
					{
						$output = "{0} Minor version limit NO LIMIT" -f $output
					}
					else
					{
						$output = "{0} Minor version limit {1}" -f $output,$list.MajorWithMinorVersionsLimit
					}
				}
				Write-Output $output
			}
		}
	}
}

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.