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've disabled versioning on a document library that has grown to 4GB in size for only around 900 documents. Although the versioning is no longer enabled the previous versions of the documents still exist in the AllDocStreams table in the content database. How do I get SharePoint to automatically release the space used by the no longer used versions of the documents?

I'd read somewhere that the unused documents are removed when the user next updates the document and SharePoint determines the previous versions are no longer required. However, I'd prefer to release the space immediately if possible.

share|improve this question
up vote 1 down vote accepted

Here are two solutions using PowerShell:
PowerShell Script to Delete All Versions in a Document Library
SharePoint PowerShell: Delete old versions of documents and items.

Essentially this should work (from first link):

$web = Get-SPWeb http://localhost
foreach ($list in $web.Lists)
  # examine if BaseType of list is NOT a Document Library
  if ($list.BaseType -ne "DocumentLibrary") 
    # forget the rest and return to top
  # loop through each item
  foreach ($item in $list.Items)
    # work with the file object as we're in a document library
    $file = $item.File
    # delete all versions

I tested the $file.Versions.DeleteAll() and it worked for me

share|improve this answer
I have some event receivers attached to this list that I wouldn't want to fire. Would the "Versions.DeleteAll()" fire them? Also, does this only remove the previous versions and leave the current version in place? – Brian Scott Sep 18 '12 at 13:45
When I tested it did not delete my current version, but I strongly suggest you test this yourself! When it comes to firing the event I'm not sure. By the way, I just found this:… seen it? – eirikb Sep 18 '12 at 13:48
It's DeleteAllMinorVersions ! – eirikb Sep 18 '12 at 13:50
@Eirkib: Thanks, I'll check this out. – Brian Scott Sep 18 '12 at 14:02
Hi, it looks to me like DeleteAll() was the correct choice, this remove all current major versions other than the current live one. – Brian Scott Sep 19 '12 at 8: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.