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: “/”


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

By Rijwan Ansari

MVP, CSM, CSPO, MCP, MCTS. Sr. Software Developer. Expertise in ASP.NET MVC, Angular, AngularJs, .Net Core, C#.NET, Azure, Cognitive Services, Machine Learning, SharePoint, Azure Services, and tools, Requirement Analysis, Team Management, Pre-Sales and more. Ability to work independently and Team, handle pressure and meet commitment. Excellence Communication and adjust in any environment

Leave a Reply

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