I need to delete all site collections that contains personal in it. I get all the site collections by the cmdlet

$sites= get-spsite -limit all| Where {$_.url -like "*personal*"}
foreach($site in $sites)
Remove-spsite -identity $site

I get an error cannot convert spsite to Spsitepipebind

1 Answer 1


Instead of removing sites in foreach try passing it to Remove-SPSite using pipeline:

Get-SPSite -Limit ALL | Where-Object { $_.Url -Like "*personal*" } | Remove-SPSite

Or shorter version:

Get-SPSite -Limit ALL | ? Url -like *personal* | Remove-SPSite
  • 1
    There is a typo in your code it needs to be $_. and not $. Sep 1, 2015 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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