Globally configure the default number of versions for SharePoint Document Libraries

By default, when turning on versioning in SharePoint, the number of versions is unlimited.  

This is obviously a problem in terms of long term management.  How can the default number of versions be set or propagated?

I have a SQL query that gives me which lists (url and guids) have versioning turned on but I'm looking for the stsadm, webservice or similar command to set the version limit property value.
OCSDTechAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

liebrandCommented:
There is no way out of the box to solve this problem.
0
quihongCommented:
Like all SP administrator, I have this exact same issue.

Our solution (not yet implemented) will be a Powershell Script that uses the SP Object Model.

Here is a tutorial to get you get started - http://www.u2u.info/Blogs/karine/Lists/Posts/Post.aspx?ID=10

I'll try to provide a more specific code sample later today.
0
quihongCommented:
Here is a Powershell script that list out all Document Libraries within a WebApp that has Document Versioning enabled. It list it out to a csv file.

Uncomment the if statement to set the limit.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
# Create the stopwatch
[System.Reflection.Assembly]::LoadWithPartialName("System.Diagnostics.Stopwatch") > $null
$sw = New-Object System.Diagnostics.StopWatch
$sw.Start()

$logFile = "C:\DocumentVersioningEnabled.csv"
$startime = Get-Date
"Script Starting..." + $startime | Out-File -filepath $logFile
"SiteURL`tTitle`tType`tCreatedBy`tEnableVersoning`tEnableMinorVersions`tMajorVersionLimit`tMajorWithMinorVersionsLimit`tCreated`tLastItemModifiedDate`tItemCount" | Out-File -filepath $logFile -append

$WebAppURL =  "http://eportal"
$theSite = New-Object Microsoft.SharePoint.SPSite($webAppURL)
$webApp = $theSite.WebApplication
$allSiteCollections = $webApp.Sites

foreach($site in $allSiteCollections)
{
	foreach($web in $site.AllWebs)
	{
		foreach($list in $web.Lists)
		{
			if($list.EnableVersioning -and $list.Title -ne "Master Page Gallery" -and $list.GetType().Name -eq"SPDocumentLibrary")
			{
				$web.URL + "`t" + $list.Title + "`t" + $list.GetType().Name + "`t" + $list.Author.Name + "`t" + $list.EnableVersioning + "`t" + $list.EnableMinorVersions + "`t" + $list.MajorVersionLimit + "`t" + $list.MajorWithMinorVersionsLimit + "`t" + $list.Created + "`t" + $list.LastItemModifiedDate + "`t" + $list.ItemCount | Out-File -filepath $logFile -append
			
	
				#if($list.MajorVersionLimit -eq 0)
				#{
				#	$list.MajorVersionLimit = 5
				#	$list.update()
				#}
				#if($list.EnableMinorVersions -and $list.MajorWithMinorVersionsLimit -eq 0)
				#{
				#	$list.MajorWithMinorVersionsLimit = 5
				#	$list.update()
				#}			
			}	
		}		
		$web.Dispose()
	}
	$site.Dispose()
}
$Thesite.Dispose()

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OCSDTechAuthor Commented:
quihong,

Great solution.  I modified the script so that only one library would be changed.  Tested it with Powershell 1.0 and it worked.  

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.