Skip to content

Instantly share code, notes, and snippets.

@nigamankit7
Last active December 13, 2015 21:18
Show Gist options
  • Save nigamankit7/4975749 to your computer and use it in GitHub Desktop.
Save nigamankit7/4975749 to your computer and use it in GitHub Desktop.
This powershell script for SharePoint 2010 iterate through each site collection in a given web application. First it moves content from each web recycle bin to site collection recycle bin and then delete it from the site collection "Admin Recycle Bin" URL Shortcuts for accessing Recycle bin: /_layouts/recyclebin.aspx - For Web Recycle Bin /_layo…
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$WebApp=get-spwebapplication "http://webapplicationname"
foreach ($SPSite in $webApp.Sites)
{
foreach($SPWeb in $SPSite.AllWebs)
{
$SPWeb.RecycleBin.MoveAllToSecondStage();
write-host "Web Recycle Bin Items Deleted for:"
write-host $SPWeb.title ":" $SPWeb.URL "`n"
}
$SPSite.RecycleBin.DeleteAll();
write-host "Administrator Recycle bin Items Deleted for:" $SPSite.RootWeb.title "`n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment