This PowerShell script will take a site collection URL as input and
will then itterate through each sub web in the site collection, clearing
it's recycle bin before finally clearing the site collection recycle
bin at the end.
This script is very useful if you're moving site collections around after mass item activity, such as migrations. Running this script against your site collection will cleanup space in the database so it can be de-bloated from it's post migration state.
[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();
This script is very useful if you're moving site collections around after mass item activity, such as migrations. Running this script against your site collection will cleanup space in the database so it can be de-bloated from it's post migration state.
[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();
Delete-Site-Recycle-Bin.ps1 http://MySharePointSiteCollectionURL
No comments:
Post a Comment