Solved

Problems emptying SharePoint 2010 recycle bin

Posted on 2012-12-26
9
1,301 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
  • 5
  • 4
9 Comments
 
LVL 38

Expert Comment

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

Expert Comment

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

Author Comment

by:MisUszatek
Comment Utility
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
 
LVL 38

Accepted Solution

by:
Justin Smith earned 500 total points
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:MisUszatek
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Is there some sort of SQL maintenance going on?  You may try restarting the SQL service
0
 

Author Comment

by:MisUszatek
Comment Utility
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now