Set SharePoint Web Application Recycle Bin Configuration with PowerShell

In continuation of my article SharePoint Recycle bins – Let’s get it crystal clear, There are situations to set SharePoint to recycle bin options programmatically with either object model code (C#) or with PowerShell.

SharePoint PowerShell Script to Configure Recycle Bin:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get the Web Application
$WebApp = Get-SpWebApplication ""

#*** Set Recycle bin Options ***
#Enable Recycle bin
$WebApp.RecycleBinEnabled = $true

#Set Retention Period to 90 days
$WebApp.RecycleBinRetentionPeriod = 90 
#To Turnoff Recycle bin Retention, use: $WebApp.RecycleBinCleanUpEnabled=$false

#Set Second Stage Recycle bin Quota %
$WebApp.SecondStageRecycleBinQuota = 100
#To turn OFF Second Stage recycle bin, use: $WebApp.SecondStageRecycleBinQuota = 0

#Apply the changes

Write-Host "Recycle bin Settings Updated!"

SharePoint Recycle bin configuration with STSADM:

  • stsadm -o setproperty -pn Recycle-bin-enabled -pv {On | Off} -url <web-app-url>  
  • stsadm -o setproperty -pn Recycle-bin-cleanup-enabled -pv {On | Off} -url <web-app-url>
  • stsadm -o setproperty -pn Recycle-bin-retention-period -propertyvalue <Numeric value indicating the number of days> [-url] <URL>
  • stsadm -o setproperty -pn Second-stage-recycle-bin-quota -pv 60 -url <web-app-url>

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *