Recycle bin settings for SharePoint 2010 Web Application


In this article we will be seeing how to configure recycle bin settings for Sharepoint 2010 web application using object model and powershell.

Microsoft SharePoint Server 2010 supports two stages of Recycle Bins.

  • First-stage Recycle Bin.

  • Second-stage Recycle Bin.

When a user deletes an item, the item is automatically sent to the first-stage Recycle Bin. By default, when an item is deleted from the first-stage Recycle Bin, the item is sent to the second-stage Recycle Bin. A site collection administrator can restore items from the second-stage Recycle Bin. Go to Central Administration => Web Applications =>Manage Web Applications => Select the web application.

In the ribbon interface go to Manage => General Settings.



Using SharePoint object model:

  • Open Visual Studio 2010.

  • Go to File => New => Project.

  • Select the Console Application template from the installed templates.

  • Enter the Name and click on Ok.

  • Add the following assembly.

Microsoft.SharePoint.dll

  • Add the following namespaces.

using Microsoft.SharePoint.Administration;

using Microsoft.SharePoint;

  • Program.cs:

  1. using System;

  2. using System.Collections.Generic;

  3. using System.Linq;

  4. using System.Text;

  5. using Microsoft.SharePoint.Administration;

  6. using Microsoft.SharePoint;

  7. namespace RecycleBinSettings

  8. {

  9. class Program

  10. {

  11. static void Main(string[] args)

  12. {

  13. SPWebApplication webApp =SPWebApplication.Lookup(newUri("https://anavijai.com/"));

  14. // -------------SharePoint Recycle Bin Settings -------------------------------------

  15. }

  16. }

  17. }


Recycle Bin Status:



  1. webApp.SecondStageRecycleBinQuota = 50;

  2. // -------------for Off option to be enabled

  3. webApp.SecondStageRecycleBinQuota = 0;

  4. Update the changes:

webApp.Update(); PowerShell script:

  • Go to Start => All Programs => Microsoft SharePoint 2010 products => SharePoint 2010 Management Shell.

  • Run as an administrator.

  • Run the following script to get the installed languages.

  1. $webApp = get-spwebapplication "https://anavijai.com/"

  2. # -------------SharePoint Recycle Bin Settings-------------------------------------

  3. $webApp.RecycleBinEnabled = $true

  4. $webApp.RecycleBinRetentionPeriod = 30

  5. $webApp.RecycleBinCleanupEnabled = $truee

  6. $webApp.SecondStageRecycleBinQuota = 50

  7. $webApp.Update()