I currently have a SharePoint 2013 environment which was upgraded from SharePoint 2010 a year or so ago.. the versioning on some document libraries where set to unlimited versions, and was consuming a lot of additional space (on some document libraries around 30GB). I have decided to remove the versioning to back to 5 (the 5 latest versions).
The below script has had some success - and when running on multiple document libraries it has remove versioning, but on files within the same document library the versioning hasn't been removed.
Example: Before running the script file 1 = had 100 versions file 2 = had 100 versions
After running the script file 1 = has 5 versions file 2 = has 100 versions
$SPweb = Get-SPweb "xxxxx" ##EDIT AND PUT THE WEB ADDRESS HERE##
$versionsToKeep =5; ##NUMBER OF VERSIONS TO KEEP##
$SPlist = $SPweb.Lists["Document Library"] ##THE DOC LIBRARY##
foreach ($SPitem in $SPlist.Items)
{
$currentVersionsCount= $SPItem.Versions.count
if($currentVersionsCount -gt $versionstoKeep)
{
for($i=$currentVersionsCount-1; $i -ge $versionstoKeep; $i--)
{
$SPItem.versions[$i].delete()
}
}
}
I'm unsure why this would be - and if anyone else has had these issues previously?