How to Delete a Host Named Site Collection in SharePoint using PowerShell?

Requirement: Delete host named site collection using PowerShell in SharePoint.

How to Delete host named Site Collection?

Generally, Host named site collections in SharePoint is managed through PowerShell. Prior to SharePoint 2013, You cannot delete host-named site collections from the Central Administration site as the delete button is greyed out on the delete site collection page. However, from SharePoint 2013 you can delete either host-named site collection or path-based site collection from:

  • Central Administration >> Application Management >> Delete Site Collection
  • Select the site collection from the drop down and hit “Delete” button
  • Confirm the prompt once to delete the host named site collection.
delete host named site collection powershell

Delete host named site collection using PowerShell:

To delete a Host named site collection using PowerShell, use Remove-SPSite cmdlet in SharePoint Management Shell.

Remove-SPSite -Identity "http://Host-Named-Site-Collection-URL"

This removes the given host named site collection.

Permanently remove the deleted site collection:

If case, you want to re-use the same URL or free-up disk space occupied by the deleted site collection, you have to permanently delete the site collection with PowerShell. use Remove-SPDeletedSite cmdlet to remove deleted site collections permanently. 

Get-SPDeletedSite | Remove-SPDeletedSite
sharepoint 2013 delete host named site collection

This removes host named site collection permanently.

Get All Host Named Site Collections:
To get all host named site collections in a SharePoint Web application, use this PowerShell script.

$webApp = Get-SPWebapplication "http://web-application-url"

foreach($Site in $WebApp.Sites)
   if ($Site.HostHeaderIsSiteName)
       Write-Host $Site.Url 'is host-named Site Collection' 
       Write-Host $Site.Url 'is path based Site Collection' 

Here is my another post on deleting site collections in SharePoint How to Delete Site Collection using PowerShell in SharePoint?

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply