Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problems emptying SharePoint 2010 recycle bin

Posted on 2012-12-26
9
Medium Priority
?
1,433 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 38

Accepted Solution

by:
Justin Smith earned 2000 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

670 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