Solved

Problems emptying SharePoint 2010 recycle bin

Posted on 2012-12-26
9
1,378 Views
Last Modified: 2012-12-27
I deleted a bunch of sites from my test site collection on SharePoint 2010. I need to empty all possible stages of the recycle bin to make the database as small as possible. I am currently stuck with one large site sitting in the Site Collection Recycle Bin > Deleted from end user Recycle Bin. The size of this site is about 30GB.

When I am using the UI and try to delete this site it is unresponsive for a while but when it comes back the site is still there. Then I found this Powershell script:

$WebApp=get-spwebapplication "http://mytestserver/"
 
    foreach ($SPSite in $webApp.Sites)
    {
         #get the collection of webs
      foreach($SPWeb in $SPSite.AllWebs)
         {
             #Empty the 1st Stage Recycle bin items PERMENANTLY
             #$SPWeb.RecycleBin.DeleteAll();
              
             #Send the 1st Stage Recycle bin items to 2nd Stage
             $SPWeb.RecycleBin.MoveAllToSecondStage();
 
              write-host "End-User Recycle Bin Items Deleted for:"
              write-host $SPWeb.title ":" $SPWeb.URL "`n"
         }
             #Empty SharePoint site collection recycle bin (2nd Stage Recycle bin) or Admin Recycle bin
             $SPSite.RecycleBin.DeleteAll();
 
  write-host "Administrator Recycle bin Items Deleted for:" $SPSite.RootWeb.title "`n"
    }

Open in new window


When I run it it gives me the following error:

Exception calling "DeleteAll" with "0" argument(s): "The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun you
r statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check f
or long-running transactions."
At line:18 char:42
+              $SPSite.RecycleBin.DeleteAll <<<< ();
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Not sure what to do with it. Any other ideas how to empty that recycle bin?

Thanks!
0
Comment
Question by:MisUszatek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 38

Expert Comment

by:Justin Smith
ID: 38722507
Need to use the Get-SPDeletedSite and Remove-SPDeletedSite commandlets.
0
 
LVL 38

Expert Comment

by:Justin Smith
ID: 38722508
Also, may need to run the Gradual Site Delete timer job.
0
 

Author Comment

by:MisUszatek
ID: 38722520
I am not too good with PS. Can you write a sample commands for me? I can bump this question up to 500 or create another one.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 38

Accepted Solution

by:
Justin Smith earned 500 total points
ID: 38722536
To get a list of the sites in the recycle bin....

Get-SPDeletedSite -WebAPplication http://urlofwebapp


To remove a site.....

Remove-SPDeletedSite -WebApplication http://urlofwebapp -Identity <either the ID from th list above, or a server relative URL like /sites/name>
0
 

Author Comment

by:MisUszatek
ID: 38722557
It doesn't show anything after running the Get-SPDeletedSite -WebApplication http://urlofwebapp... I can still see that deleted site in the UI...
0
 
LVL 38

Expert Comment

by:Justin Smith
ID: 38722601
Ok so you are talking about a sub-site in the regular recycle bin, not a site collection in the site collection recycle bin.

Are there other site collections in the web app?  One option is to disable the recycle bin on the web application, which would automatically empty everything.  Then you could turn it back on.  

Something else you can try is to restore the site, then use PowerShell to delete it (which will bypass the recycle bin).
0
 

Author Comment

by:MisUszatek
ID: 38725189
I tried disabling the recycle bin but got the same error message after a while:

The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions.

How can I change sql configuration to make this work?
0
 
LVL 38

Expert Comment

by:Justin Smith
ID: 38725246
Is there some sort of SQL maintenance going on?  You may try restarting the SQL service
0
 

Author Comment

by:MisUszatek
ID: 38725543
No maintenance. Restarted but still the same problem. I will copy production database again and delete unneeded sites with recycle bin disabled. I hope that will work. Thanks for all your help!
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sharepoint List View 6 44
Sharepoint 2010 2 27
Is sending authentication through SOAP secure? 3 38
sharepoint 2013 how long should Get-SPProduct -Local run for 1 23
If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question