Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problems emptying SharePoint 2010 recycle bin

Posted on 2012-12-26
9
Medium Priority
?
1,448 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

971 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