kwizcom banner advertisement

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 are managed through PowerShell. Prior to SharePoint 2013, You cannot delete host named site collections from Central Administration site as the delete button is greyed out on 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 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.

Tail: 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' 
 }
 else
 { 
  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?
How to Delete a Host Named Site Collection in SharePoint using PowerShell? How to Delete a Host Named Site Collection in SharePoint using PowerShell? Reviewed by Salaudeen Rajack on 8:22 PM Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.