PowerShell Script to Cleanup all Recycle Bins in a Site Collection in SharePoint 2013
Here is a PowerShell script which will take a site collection URL as input and then iterate through each sub web in the site collection, clearing it's recycle bin before finally clearing the site collection recycle bin at the end.
Open PowerShell window in your system.
- Paste the below code in your PowerShell window.
- Run the script.
- [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");
- $url = $args[0];
- $site = new-object microsoft.sharepoint.spsite($url);
- for ($i=0;$i -lt $site.allwebs.count;$i++)
- {
- write-host $site.allwebs[$i].url "...deleting" $site.allwebs[$i].recyclebin.count "item(s).";
- $site.allwebs[$i].recyclebin.deleteall();
- }
- write-host $site.url "...deleting" $site.recyclebin.count "item(s).";
- $site.recyclebin.deleteall();
- $site.dispose();
Gowtham RajamanickamTOP 100Posted Apr 10, 2016, 9:40 PM EDT
keep read my blogs
Gowtham RajamanickamTOP 100Posted Apr 10, 2016, 9:40 PM EDT
thanks Vijay
Vijay SPosted Jun 17, 2015, 4:55 AM EDT
Good one