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())
$siteCollection.RecycleBin.DeleteAll();
$now = Get-Date
write-host("Deleting completed at " +$now.toString())
$siteCollection.Dispose();
No comments:
Post a Comment