Create a Web Application Using PowerShell

Now that you know how to create a web application using the Central Administration GUI, it’s time to learn how to do it from script. Using a script is helpful if you need to create many web applications or regularly re-create them and need to ensure it is done consistently each time.

The PowerShell cmdlet is New-SPWebApplication. The full syntax covers most of the settings presented in Central Administration.

New-SPWebApplication -ApplicationPool <String> -Name image
<String> [-AdditionalClaimProvider image
<SPClaimProviderPipeBind[]>] [-AllowAnonymousAccess image
<SwitchParameter>] [-ApplicationPoolAccount image
<SPProcessAccountPipeBind>] [-AssignmentCollection image
<SPAssignmentCollection>] [-AuthenticationMethod image
<String>] [-AuthenticationProvider image
<SPAuthenticationProviderPipeBind[]>] [-Confirm image
[<SwitchParameter>]] [-DatabaseCredentials image
<PSCredential>] [-DatabaseName <String>] image
[-DatabaseServer <String>] [-HostHeader <String>] image
[-Path <String>] [-Port<UInt32>] [-SecureSocketsLayer image
<SwitchParameter>] [-ServiceApplicationProxyGroup image
<SPServiceApplicationProxyGroupPipeBind>] image
[-SignInRedirectProvider image
<SPTrustedIdentityTokenIssuerPipeBind>] image
[-SignInRedirectURL <String>] [-Url <String>] [-WhatIf image
[<SwitchParameter>]][<CommonParameters>]

To learn more about the various parameter values, use the following PowerShell cmdlet:

Get-Help New-SPWebApplication -detailed

NOTE When running this or any SharePoint-based PowerShell cmdlet, be sure to use the SharePoint 2010 Management Shell. It can be found at Start ⇒ All Programs ⇒ Microsoft SharePoint 2010 Products.

The following is a script that you can use to create your next web application using PowerShell. Simply adjust the values for the variables. The web application will use Classic authentication. You will also need to ensure that the account defined by $appPoolAccount is already configured as a managed account.

$name = "Extranet"
$hostHeader = "extranet.synergy.com"
$url = "https://" + $hostHeader
$port = 443
$appPoolName = "Extranet_AppPool"
$appPoolAccount = "SYNERGYSP.DefaultAppPool"
$dbServer = "sqlcluster.synergy.com"
$dbName = "Extranet_Content"
 
New-SPWebApplication -Name $name -hostHeader image
$hostHeader -Port $port -URL $url -SecureSocketsLayer image
-ApplicationPool $appPoolName -ApplicationPoolAccount image
(Get-SPManagedAccount $appPoolAccount) -DatabaseServer image
$dbServer -DatabaseName $dbName
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.47.208