Skip to content

Instantly share code, notes, and snippets.

@petersgiles
Forked from wpsmith/host-named-sites.ps1
Created July 14, 2016 22:03
Show Gist options
  • Save petersgiles/34f26e04fd160513433241442e57ca8e to your computer and use it in GitHub Desktop.
Save petersgiles/34f26e04fd160513433241442e57ca8e to your computer and use it in GitHub Desktop.
Powershell: SharePoint 2013 Create Web Application, Root Site Collection,
# Replace:
# DATABASE
# NAMED
# APPLICATION NAME
# hostheadername
# DOMAIN\USER
# DOMAIN\SP_FARM_ACCOUNT
# PATHNAME
# SITE COLLECTION NAME
# DIRECTORYPORT
# Create Authentication Provider
$ap = New-SPAuthenticationProvider
# Create Web Application
$w = New-SPWebApplication -DatabaseName "WSS_Content_DATABASE" -ApplicationPool "NAMED App Pool" -Name "APPLICATION NAME" -Port 80 -AuthenticationProvider $ap1 -ApplicationPoolAccount (Get-SPManagedAccount 'DOMAIN\SP_FARM_ACCOUNT') -Path "%wwwroot%\wss\VirtualDirectories\DIRECTORYPORT" -HostHeader "hostheadername"
iisreset /noforce
# Create Root Site Collection
$w = Get-SPWebApplication "APPLICATION NAME"
New-SPSite http://sub.domain.com -OwnerAlias "DOMAIN\USER" -HostHeaderWebApplication $w -Name "APPLICATION NAME" -Template "BLANKINTERNETCONTAINER#0"
# Create Managed Path Site Collection
New-SPManagedPath "PATHNAME" -HostHeader -Explicit
New-SPSite http://sub.domain.com/PATHNAME -OwnerAlias "DOMAIN\USER" -HostHeaderWebApplication $w -Name "SITE COLLECTION NAME" -Template "BLANKINTERNETCONTAINER#0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment