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 = "Portal.Crescent.com"
$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

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
$SiteURL="http://portal.crescent.com"
$SiteName="Crescent Portal"
$SiteOwner="Crescent\SP_Farm"
$SiteTemplate="STS#0"

#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.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...