4

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

6

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 $. – user1339913 Sep 1 '15 at 17:11

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.