Hi all
I need to delete the First and Second stage Recycle bin for all of our personal sites, as the total size of these has somehow exceeded 140GB.
I am however stuck as to how to do this. I have tried lots of Powershell scripts to get this done, but nothing has worked. I also tried to just switch off the Recycle Bin but this operation just times out, as the Bin is too large now for this to work.
My most recent Powershell script that I tried is the only one that didnt throw any errors and seemed to do something for about 6 seconds, but checking the recycle bin for the site I tried it against shows that it is still full:
param([string]$Url, [switch]$help) [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") function GetHelp() { $HelpText = @" DESCRIPTION: NAME: Remove-SPSiteSecondStageRecycleBin Empties the second-stage recycle bin for a Microsoft.SharePoint.SPSite Collection PARAMETERS: -url Url to SharePoint Site Collection SYNTAX: Remove-SPSiteSecondStageRecycleBin -url http://ansafile Empties the second stage recycle bin for the SiteCollection. Remove-SPSiteSecondStageRecycleBin -help Displays the help topic for the script "@ $HelpText } function Remove-SPSiteSecondStageRecycleBin([string]$url) { $siteCollection = New-Object Microsoft.SharePoint.SPSite($url); $recycleQuery = New-Object Microsoft.SharePoint.SPRecycleBinQuery; $recycleQuery.ItemState = [Microsoft.SharePoint.SPRecycleBinItemState]::SecondStageRecycleBin; $recycleQuery.OrderBy = [Microsoft.SharePoint.SPRecycleBinOrderBy]::Default; $recycledItems = $siteCollection.GetRecycleBinItems($recycleQuery); $count = $recycledItems.Count; for($i = 0; $i -lt $count; $i++) { $g = New-Object System.Guid($recycledItems[$i].ID); $recycledItems.Delete($g); } $siteCollection.Dispose() } if($help) { GetHelp; Continue } if($url) { Remove-SPSiteSecondStageRecycleBin -url $url }
After pressing Enter after adding the above, I then entered the below into Powershell:
Remove-SPSiteSecondStageRecycleBin -url http://ansafile
This seemed to do something, but not what I needed it to do, ie delete the recycle bin for the whole sharepoint installation. ANSAFILE is the internal name of the Sharepoint site. Also, I am using Powershell v2, in an ISE window. My server is running Windows
Server 2008 Std x64 edition. Sharepoint version is 12.0.0.6565
Hopefully someone can help, as I have never used Powershell before, and had to take over the Sharepoint which I have never done before either, and its a bit of a struggle
Thanks to all
Naz