Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

we innadvertantly had versioning enabled on a heavily used list and the database table "alldocsversions" has grown to 225 Gb. Can anyone suggest a way in which we can rid ourselves of the previous versions and thus shrink the size of the database

share|improve this question

1 Answer 1

Darko Milevski has a post on this exact issue:

http://mkdot.net/blogs/darko/archive/2011/04/05/sharepoint-document-versions-and-how-to-manage-delete-them.aspx

He uses the following script to remove the versions.

$snap = Get-PSSnapin | Where-Object {$_.Name -eq ‘Microsoft.SharePoint.Powershell’}
if ($snap -eq $null) {
Add-PSSnapin Microsoft.SharePoint.Powershell
}
#Set site url ‘http://<servername>/site’. ‘sps2010’ is my test sharepoint server
$siteurl = “http://sps2010/test”
#Document Library Name. ‘VersionsTestDL’ is my test document library
$dlname = "VersionsTestDL"

#get site obj
$site=new-object Microsoft.SharePoint.SPSite($siteurl)
#open root web
$web = $site.OpenWeb()
#get doclib
$dl = $web.Lists[$dlname]

foreach ($doc in $dl.Items)
{
  #Delete All Versions
  $versions = [Microsoft.SharePoint.SPListItemVersionCollection]$doc.Versions
  $versions.DeleteAll()
  #If you want to move them to Recycle Bin only  and not to delete them forever, use RecycleAll() method 
}
$dl.Update()

$web.dispose()
$site.dispose()

Just as Darko has done, you should test your scripts out before running in production (and I would recommend after a backup)

Due note that to "reclaim" that space you will have to shrink your database, and probably will want to defrag it afterwards. you can review the DB Maintenance white paper from MS here covering both:http://technet.microsoft.com/en-us/library/cc262731(v=office.12).aspx

This should not cause you any issues with specific SBS integrated tools.

share|improve this answer
    
Jesus thanks that is great, it does however say that the powershell script os for sharepoint 2010 which is later than the version that ships with sbs2008. However, we will trya it and report back –  Andrew Rosamond Nov 2 '11 at 16:56

Your Answer

 
discard

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.