web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Sample PowerShell script to create web application and a site collection in SharePoint 2013

Nishant Rana Profile Picture Nishant Rana 11,325 Microsoft Employee

Just sharing a sample script that we are using to create a web application and a site collection of type publishing in it.

 

# SharePoint cmdlets
Add-PsSnapin Microsoft.SharePoint.PowerShell</pre>
# Set variables
$WebAppName = "MyAppPool"
$WebAppHostHeader = "servername"
$WebAppPort = "portnumber"
$url = "http://servername"
$WebAppAppPool = "MyAppPool"
# This User has to be a Sharepoint Manager Account
$WebAppAppPoolAccount = "domain\username"
$AuthenticationMethod = "NTLM"
$ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos

# Create a new Sharepoint WebApplication
New-SPWebApplication -Name $WebAppName -Port $WebAppPort -HostHeader $WebAppHostHeader -URL $url -ApplicationPool $WebAppAppPool -ApplicationPoolAccount (Get-SPManagedAccount $WebAppAppPoolAccount) -AuthenticationMethod $AuthenticationMethod -AuthenticationProvider $ap

# Set variables
$SiteCollectionName = "MySiteCollection"
$SiteCollectionURL = "http://servername:portnumber/"
$SiteCollectionTemplate = "BDR#0"
$SiteCollectionLanguage = 1033
$SiteCollectionOwner = "LSS\lssspadmin"

# Create a new Sharepoint Site Collection
New-SPSite -URL $SiteCollectionURL -OwnerAlias $SiteCollectionOwner -Language $SiteCollectionLanguage -Template $SiteCollectionTemplate -Name $SiteCollectionName

Hope it helps ..


Filed under: SharePoint, SharePoint 2010, SharePoint 2013 Tagged: SharePoint, SharePoint 2010, SharePoint 2013

This was originally posted here.

Comments

*This post is locked for comments