We here at StratexSystems believe in utilising tools that help perform tasks efficiently and ultimately make our daily work with SharePoint easy.
One such tool is SharePoint Management Shell or as it is more commonly referred to 'Windows Powershell'. This is used to manage SharePoint through the use of command lines - custom command-lets, instead of going through SharePoint Central Administration.
We came across a situation in one of our Client projects recently where, we were processing a large amount of data into one SharePoint environment, which was then to be imaged onto a second SharePoint environment. There was redundant data, for example primarily thousands of rows in the Recycle Bin that were unnecessarily taking space and time to process for the image of the second SharePoint environment.
A quick solution to was to use Powershell to clear the bulk data from the Recycle Bin. Here is the process and command script we used:
- Open SharePoint Management Shell (right click and select Run as Administrator)
- Modify Site collection Url in following script and execute:
$sitecollectionUrl = "ENTER YOUR SHAREPOINT SITE URL" $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();
Process time will obviously depend on the amount of data to be cleared, once the script has finshed some stats will appear to help give an analysis.
This is a prime example, one of many in Powershell where going through Site Settings in SharePoint or through Central Administration is not practical or feasible.