Solved

Problems emptying SharePoint 2010 recycle bin

Posted on 2012-12-26
9
1,341 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 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