Monday, May 13, 2013

Set SharePoint Web Application Recycle Bin configuration Programmatically with PowerShell

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:
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>

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...