Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Last active April 27, 2017 15:30
Show Gist options
  • Save wpsmith/6a96d808f2c72896e05b to your computer and use it in GitHub Desktop.
Save wpsmith/6a96d808f2c72896e05b 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