SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to reset the number of versions to "2" for all lists and libraries that have version control enabled. Is there a PowerShell script or something that can handle this? The idea here is to get a handle on our runaway storage.


share|improve this question

A little iteration trough all webs and all lists checking if versioning is enabled and if so setting majorversion limit to 2. Then you need to update each item to delete all other versions:

$site = Get-SPSite http://mycoolsitecollection
$webs = $site.AllWebs

foreach ($web in $webs) {
  foreach($list in $web.Lists) {
    if($list.EnableVersioning) { 
      $list.MajorVersionLimit = 2
      foreach($item in $list.Items) {

Keep in mind: if you set limit to 2 there will be 3 versions visible when looking at version history (current and last 2).

Also if you have large lists foreach ($item in $list.Items) on items can take a while.

share|improve this answer

You can find a basic idea here in Powershell:

Have a look at for all methods supported. For example you might want to delete just the minor versions.

It might also be a good idea to review the doc library settings and update these to a setting that creates less versions (for example cull all minor versions after two major versions) while you are looping through the document libraries.

share|improve this answer
Awsome! Thanks Guys – Bismarck Apr 26 '12 at 14:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.