Delete SharePoint SiteCollection via array of URLs


Microsoft PowerShell script to delete Microsoft SharePoint SiteCollections based on a given array of URLs.

# Array of SiteCollection
$urls = @(

# Load PowerShell Add-In
Add-PSSnapin Microsoft.SharePoint.PowerShell

# Iterate through array
ForEach ($url in $urls) {
    try {
        # Try to remove the SiteCollection
        Remove-SPSite $url
        Write-Output "SiteCollection $url deleted successfully." | Write-Host -ForegroundColor Cyan
    } catch {
        Write-Output "Something went wrong on SiteCollection $($url)." | Write-Host -ForegroundColor Red
        Write-Output "   $($_.Exception.Message)" | Write-Host -ForegroundColor Red

About Author

Christian Unnerstall

Christian Unnerstall, founder of, enjoys designing and building things that look nice and work well, whether it's websites or services within the interwebs. Have questions - feel free to reach out to him. Enjoy

Leave a Reply