In continuation to my article SharePoint Recycle bins - Lets get it crystal clear , There are situations to set SharePoint recycle bin options programmatically with either object model code (C#) or with PowerShell.
SharePoint 2010 powershell Script to Configure Recycle Bin:
SharePoint Recycle bin configuration with STSADM:
SharePoint 2010 powershell Script to Configure Recycle Bin:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Get the Web Application $WebApp = Get-SpWebApplication "http://SharePoint.crescent.com" #*** 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 $WebApp.Update() 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>