PowerShell – Delete all “deleted” site collections in a web application
When you delete a site collection, it actually stays kicking around for a while, as explained at http://blogs.msdn.com/b/chaks/archive/2011/06/30/sharepoint-2010-sp1-site-recycle-bin-ui-experience.aspx.
As I happened to have a lot of deleted site collections I wanted to permanently remove, I was not satisfied with having to manually grab the site collection ID’s and plunk them into the Remove-SPDeletedSite PowerShell command one-by-one.
So, below is the method to delete ALL the “deleted” site collections under a specified web application. In this case, the web application URL is http://sharepoint – replace with your own desired web app URL:
Get-SPDeletedSite -webapplication http://sharepoint | Remove-SPDeletedSite
You will be prompted to delete them one by one, if you want it to run through them all without further prompts just enter the letter “A”.