Friday, March 15, 2013

Create New Web Application in SharePoint 2013 using PowerShell

To Create new web application in SharePoint 2013, head on to SharePoint 2013 Central Administration site. Navigate to:

  • Application Management >> Manage web applications
  • Click on "New" button from the ribbon
  • Fill-out the details for your new web application. Such as: Web and click on "Create" to create a web application in SharePoint 2013.
    powershell script to create web application in sharepoint 2013
Create Web Application in SharePoint 2013 using PowerShell:
Here is my PowerShell script to create web application in SharePoint 2013:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Define Variables for Web Application Creation
$WebAppName = "Crescent Portal"
$HostHeader = ""
$WebAppURL = "http://"+$HostHeader
$WebAppPort = 80
$ContentDBName = "SP13_Content_Portal"
$AppPoolName = "Portal AppPool"
$AppPoolAccount = "Crescent\SP_Farm"
$AppPooPassword = "<<Password>>"

#Authentication Provider
$AuthProvider = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos

#Create new Managed Account
$SecurePassword = ConvertTo-SecureString -String $AppPooPassword -AsPlainText -Force
$cred = new-object -typeName System.Management.Automation.PsCredential -argumentlist $AppPoolAccount,$SecurePassword
New-SPManagedAccount -Credential $cred

#Create new Web Application
New-SPWebApplication -name $WebAppName -port $WebAppPort -hostheader $HostHeader -URL $WebAppURL -ApplicationPool $AppPoolName -ApplicationPoolAccount (Get-SPManagedAccount $AppPoolAccount) -AuthenticationMethod NTLM -AuthenticationProvider $AuthProvider -DatabaseName $ContentDBName
Lets make use of an existing managed account this time:
$AuthProvider = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos
New-SPWebApplication -Name "Crescent Portal" -Port 80 -HostHeader "" -DatabaseName "SP16_CrescentPortal_Content" -URL "" -ApplicationPool "Crescent Portal AppPool" -ApplicationPoolAccount (Get-SPManagedAccount "Crescent\Sp2016_Service") -AuthenticationProvider $AuthProvider
How about SSL Enabled Web Application?
$AuthProvider = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos
New-SPWebApplication -Name "Crescent Internet" -ApplicationPool "Crescent Internet AppPool" -ApplicationPoolAccount (Get-SPManagedAccount "Crescent\SPS2016_AppPool") -URL "" -Port 443 -HostHeader "" -DatabaseName "SP16_CrescentInternet_Content01" -Path "C:\Crescent_Internet" -SecureSocketsLayer -AuthenticationProvider $AuthProvider

This creates a new web application using PowerShell for SharePoint 2010 or SharePoint 2013. But wait! You are not yet done. You got to create the root site collection for the web application. If you try to browse to the web application without creating top-level site collection, you'll get "HTTP 404" error!

Create Top-Level Site Collection with PowerShell:
#Create Top-Level Site collection in SharePoint 2013
$SiteName="Crescent Portal"

#Create new Site collection
New-SPSite –url $SiteURL -Name $SiteName -OwnerAlias $SiteOwner -Template $SiteTemplate

Although this script is written to create web application with PowerShell for SharePoint 2013, It can be also used in creating a web application for SharePoint 2010 too.

SharePoint 2013 PowerShell to create web application in classic mode:
Just leave the AuthenticationProvider parameter in the above script to create new web application in Classic mode.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:


  1. what is the command for formsbased authentication ?

    1. Use: $ap = New-SPAuthenticationProvider -Name "ClaimsForms" -ASPNETMembershipProvider -ASPNETRoleProviderName


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...