I've created a managed path for my team sites - called "workspaces". All team sites Have been created under the same managed path.


How can I list all team sites under a managed path?

What I want is to delete all site collection under a specific managed path. (remove site collection and DB-entry)


To list them, this actually gives you all sites under the path though:

Get-SPSite "http://awesome.com/workspaces*" -Limit ALL

To delete you should be able to use

Get-SPSite "http://awesome.com/workspaces*" -Limit ALL | Remove-SPSite -Confirm:$false

You can use

Remove-SPContentDatabase -Identity {GUID}

to remove a content database

  • 1
    ty, do this code delete the team-site-db? – Plexus81 Aug 8 '14 at 8:24
  • No it does not, it just removes the site collections from the database. – Robert Lindgren Aug 8 '14 at 8:25
  • Updated with how you can remove a content database if needed – Robert Lindgren Aug 8 '14 at 8:30

You can delete site collection using powershell by using following command

$tmpRoot = Get-SPWebApplication -Identity http://SP:2000
#Enumerate through each site collection
for ($index=$tmpRootColl.Count-1 ; $index-ge 0 ; $index–-)
  Remove-SPSite -Identity $tmpRootColl.Item($index) -GradualDelete -Confirm:$false
Get-SPDeletedSite | Remove-SPDeletedSite

Where $tmpRoot is Web Application and $tmpRootColl is collection of sites under web application

Find full code with explanation from this blog CodePlayAndLearn

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.