Friday, August 9, 2013

Empty SharePoint Recycle bin using PowerShell

Below script will delete all the Items from the Recycle bin and Site Collection recycle bin in SharePoint.

if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
Add-PSSnapin Microsoft.SharePoint.PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-null

$sitecollectionUrl = http://sitename:portnumber
$siteCollection = New-Object Microsoft.SharePoint.SPSite($sitecollectionUrl)
write-host("Items to be deleted : " +$siteCollection.RecycleBin.Count.toString())
$now = Get-Date
write-host("Deleting started at " +$now.toString())
$now = Get-Date
write-host("Deleting completed at " +$now.toString())

Related Posts Plugin for WordPress, Blogger...