This error occurs while creating SharePoint site collection.

Error Occurs while executing below ps script:

$web = Get-SPWebApplication http://spapp:1400/
New-SPSite http://spapp:1400/ -OwnerAlias "ad\farmUser" -HostHeaderWebApplication $web -Name "Demo Team Site<Site name>" -Template STS#0

Exact error:

New-SPSite : The URL "http://Intranet" is in use as an alternate access URL or as the URL of a host header site.  
Please choose a different URL and try again.
At line:3 char:1
   + New-SPSite http://Intranet  -OwnerAlias "mars\aaronp" `
   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletNewSite:SPCmdletNewSite) [New-SPSite], ArgumentException
   + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSite

Cause of Error:

SharePoint prevents the creation of a host-named site collection with the same URL as a Web application.

If you want to create a Root Site Collection a the top level of your Web application you should not use the parameter: -HostHeaderWebApplication in the New-SPSite command.

Therefore, the root site collection is created as a path-based site collection: “/”

Resolution:

Remove: -HostHeaderWebApplication $web

New Powershell scripts:

$web = Get-SPWebApplication http://spapp:1400/
New-SPSite http://spapp:1400/ -OwnerAlias "ad\farmUser" -Name "Demo Team Site" -Template STS#0

Kind Regards

Leave a Reply

Your email address will not be published. Required fields are marked *