Sometimes we come across a situation where we need to delete all site collections except the root site especially when we are migrating my site we might want to remove all existing sites and create my sites again before running migration through tools like share gate etc.
Code
Get-SPSite "http://mysharePoint.com/sites*" -Limit ALL | Remove-SPSite -Confirm:$falseto check if the sites are removed run the below PowerShell script to verify, it should return empty.
Code
Get-SPSite "http://mysharePoint.com/sites*" -Limit ALLFor my sites above script can be modified as below,
SQL
Get-SPSite "http://awesome.com/personal*" -Limit ALL | Remove-SPSite -Confirm:$false
Get-SPSite "http://awesome.com/personal*" -Limit ALL

Join the conversation! Your thoughts help the community grow.