In this PowerShell SharePoint tutorial, we will discuss What is a SharePoint web application, how to create a web application in SharePoint 2019/2016/2013 using PowerShell.
- SharePoint web application
- How to create a SharePoint web application
- SharePoint 2013/2016 extend web application
- Extend web application in SharePoint 2013 using PowerShell
- Delete web application SharePoint 2013 PowerShell
- SharePoint web application settings
If you want to try out SharePoint 2016/2019, then you can see the SharePoint 2016 installation steps, new features of SharePoint 2016 and you can download a free PDF on SharePoint 2019 installation and new features.
A SharePoint web application is a collection of one or more IIS websites configured to map incoming HTTP requests to a set of SharePoint sites. A SharePoint 2016/2013 web application is composed of an Internet Information Services (IIS) website that acts as a logical unit for the site collections that you create.
The web application also maps each SharePoint site to one or more specific content databases. SharePoint Foundation uses content databases to store site content such as list items, documents, and customization information.
When you create a web application in SharePoint Foundation, it creates an IIS website with a root folder containing a web.config file at the following location:
Let us see, how to create a web application in SharePoint 2016/2013.
In PowerShell, we can use the new-spwebapplication cmdlets to create a web application in SharePoint server like SharePoint 2010, SharePoint 2013, SharePoint 2016, and SharePoint 2019.
Below is the minimum syntax to create a web application in SharePoint. These are the minimum parameters:
New-SPWebApplication -ApplicationPool <String> -Name <String>
There are also other parameters are available, you can check in this msdn url.
Below PowerShell command to create a web application using PowerShell in SharePoint 2016/2019:
Add-PSSnapin "Microsoft.SharePoint.PowerShell" $authentication = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos New-SPWebApplication -Name "My SP2016 Web App" -Port 33779 -ApplicationPool "MySP2016AppPool" -ApplicationPoolAccount (Get-SPManagedAccount "MYSP\Administrator") -AuthenticationMethod NTLM -AuthenticationProvider $authentication
This is how we can create a web application using PowerShell in SharePoint 2013/2016/2019.
We can create a web application by using a browser from SharePoint 2013 central admin as well as we can create a web application through PowerShell.
Below is the PowerShell command to create a web application in SharePoint 2013. You can write, run and debug the PowerShell script using PowerShell ISE.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue" $name = "My Test Web Application" $port = 80 $hostHeader = "intranet.enjoysharepoint.com" $url = "http://intranet.enjoysharepoint.com" $appPoolName = "SharePoint Default Appl Pool" $appPoolAccount = Get-SPManagedAccount "EnjoySharePoint\SP_Admin" New-SPWebApplication -Name $name -Port $port -HostHeader $hostHeader -URL $url ' -ApplicationPool $appPoolName ' -ApplicationPoolAccount $appPoolAccount
Once you will execute the command, it will create a web application in SharePoint 2013.
Also, you can try the below things:
As per the Microsoft standards, we can create 10 Web Applications for the best performance and the syntax as follows.
New-SPWebApplication -ApplicationPool -Name [-AdditionalClaimProvider <SPClaimProviderPipeBind>] [-AllowAnonymousAccess ] [-ApplicationPoolAccount ] [-AssignmentCollection ] [-AuthenticationMethod ] [-AuthenticationProvider <SPAuthenticationProviderPipeBind>] [-Confirm ] [-DatabaseCredentials ] [-DatabaseName ] [-DatabaseServer ] [-HostHeader ] [-Path ] [-Port ] [-SecureSocketsLayer ] [-ServiceApplicationProxyGroup ] [-SignInRedirectProvider ] [-SignInRedirectURL ] [-Url ] [-UserSettingsProvider ] [-WhatIf ]
New-SPWebApplication -Name "COSTCO Inventory Application" -Port 55245 -HostHeader COSTCOInventory.com -URL "http://www.COSTCOInventory.com" -ApplicationPool "COSTCOInventory" -ApplicationPoolAccount (Get-SPManagedAccount "Domain\FARMADMINAccount") -DatabaseName "COSTCOInventory_DB01"
In SharePoint 2013 and SharePoint 2016, you will get below warning because from SharePoint 2013 onwards Microsoft has an obsoleted Classic authentication method which was the default till SharePoint 2010.
WARNING: The Windows Classic authentication method is deprecated in this release and the default behavior of this cmdlet, which creates Windows Classic based web application, is obsolete. It is recommended to use Claims authentication methods. You can create a web application that uses the Claims authentication method by specifying the AuthenticationProvider parameter set in this cmdlet.
Refer to the http://go.microsoft.com/fwlink/?LinkId=234549 site for more information. Please note that the default behavior of this cmdlet is expected to change in the future release to create a Claims authentication-based web application instead of a Windows Classic-based web application.
Now let us learn what is the authentication provider and various type of authentication providers.
The authentication method is a specific exchange of account credentials and other information that asserts a user’s identity. The result of the authentication method is proof, typically in the form of a token that contains claims, that an authentication provider has authenticated a user.
Type of Authentication Providers in SharePoint 2013 & 2016:
- Windows based
- Forms based
- Security Assertion Markup Language (SAML) token-based
For more information on Authentication providers https://technet.microsoft.com/en-us/library/cc262350.aspx
Now let us create the web application with default authentication provider which is “Claims-based”
A) With HOSTHeader parameter:
$ap = New-SPAuthenticationProvider New-SPWebApplication -Name "COSTCO Inventory Application" -Port 55245 -HostHeader COSTCOInventory.com -URL "http://www.COSTCOInventory.com" -ApplicationPool "COSTCOInventory" -ApplicationPoolAccount (Get-SPManagedAccount " Domain\FARMADMINAccount") -DatabaseName "COSTCOInventory_DB01" -AuthenticationProvider $ap
B) Without HostHeader parameter:
$ap = New-SPAuthenticationProvider New-SPWebApplication -Name "COSTCO Inventory Application" -Port 55245 -URL "http://www." -ApplicationPool "COSTCOInventory" -ApplicationPoolAccount (Get-SPManagedAccount "DOMAIN\ FARMADMINAccount") -DatabaseName "COSTCOInventory_DB01" -AuthenticationProvider $ap
Note: Ensure that the FARM Admin account has DB creation access in the SQL server if not you can’t create web application.
Now that we have created a web application successfully we need to create at least one site collection called “Top Level Site Collection”. Without this site collection, we can’t even access the web application we created.
We can create a web application by using the SharePoint central administration website or we can also create a web application using PowerShell. In large enterprises, usually use PowerShell to create a web application.
The user must be a member of the Farm Administrators SharePoint group to create a web application. To verify open SharePoint 2016 central administration web site. Then click on “Manage the farm administrators group” which is under the Security section.
Now to create a web application, from the SharePoint 2016 Central Administration home page click on the “Manage web applications” link which is under “Application Management”.
Then from the Ribbon click on New Web Application to create a new web application. In the create new web application dialog box, fill the below things to create a new SharePoint web application.
Claims Authentication Types
Choose Enable Windows Authentication and Integrated Windows authentication [NTML]
Sign In Page URL
In the Sign in Page URL, choose Default Sign In Page.
Give a public URL for the web application, by default it will come as http://ServerName:Port
Choose, Create new application pool.
By default, it will create an application pool the same name as your web application.
Provide Security Account for an application pool.
Database Name and Authentication:
Give the Database Server name
And Database Name
Choose Windows Authentication
Service Application Connections
Select the service applications you want to activate the Customer Experience Improvement Program:
Then click on OK to create the web application. It will take some time to create a web application. Once created successfully, it will display a message. Once the web application is ready we can create our site collection.
Let us check out some SharePoint web application settings.
In a SharePoint site, we can manage the settings or settings at various levels like web/subsite level, Site Collection level, and Web Application Level. I would like to focus on a few of the important setting should be known to all developers and SharePoint support team.
Here is the various setting we can see on Web Application level in any SharePoint version later 2010 like SharePoint 2013/2016.
- General Settings
- Resource Throttling
- Outgoing Email
- Mobile Account
- SharePoint Designer
Web Application settings can be changed/configured in Central Administration from the Application server.
Log on to Application Server with FARM Administrator account and open Central Administration.
Central Administration -> Application Management -> Manage Web Applications
Select the desired web application and click on General Settings from ribbon control.
As the name states, as part of this, we can configure various general settings at the web application level.
Few of the important settings we need to know are:
- Default Quota Template
- Person Name Actions and Presence Settings
- RSS Settings
- Web Page Security Validation
- Recycle Bin
- Maximum Upload Size
Default Quota Template
The default quota template is one option we see as part of creating the site collection. If we change the quota template at web application it will be applicable to all the site collections associated with it and for all new site collections.
What exactly quota template consists of:
Person Name Actions and Presence Settings
This is one beautiful option in SharePoint which connects with messenger/communication window using in that domain. If the SharePoint admin enables this it will show the availability /status of the user in SharePoint itself.
Alerts in SharePoint help the user to notify on various aspects. Like if the business user wanted to know all the activities performed on their business documents he/she can set up an alert. To perform that SharePoint administrator has to enable this. Admin can also set a restriction maximum no. of alerts per user on a web application.
Microsoft introduced RSS (Really Simple Syndication) from SharePoint 2007 onwards. RSS is one of the best and simple ways for a user to make news, blogs and other content in SharePoint.
RSS can be managed at 2 levels one is a Web Application and the other one is Site Collection level. Once the RSS is enabled user will get an option to add comments for any connect on-page. This really works well and handy in bigger organizations while harvesting the feedback.
By mentioning “Yes” we are enabling the RSS at the Web Application level.
Web Security validation
We often see the page/session expiration while creating a site collection from Central Administration. That will be managed at this point for every web application by default the security validation expires after 30 min, we can change as per the business needs at any point of time.
In SharePoint as soon as users delete any content from the site it will be moved to “Recycle Bin” and we can configure how many days we want to retain that content in Recycle Bin. The Recycle Bin in SharePoint exists at 2 levels one is site level and the other one is at the Site Collection level.
In fact, SharePoint Administrator can define whether the content should go to the recycle bin or delete permanently as soon as the user deletes it at the Web Application level.
Maximum Upload Size
In SharePoint administrator can specify the maximum file size accepted at the web application level.
By default, SharePoint allows 250 MB files if business demands to increase the upload size file limit you can update the same we can do it as part general settings of the web application.
For more details on file size and handling file upload, issues refer to my previous article Cannot Upload large files to SharePoint 2013.
Here we checked some web application settings in SharePoint 2013/2016/2019.
Let us see, how to extend web application in SharePoint 2013 using PowerShell and using SharePoint 2013 central administration.
In any SharePoint web application, we could see 2 types of users Internal or External. If we want to collaborate on the SharePoint site with both Internal and External users the best approach from Microsoft is to Extend the Web Application.
Once we extend the web application we can configure a different set of permissions to that users. However, both web applications communicate the same Content Database.
Note: When you extend the Web Application SharePoint creates only a new IIS site in Application Pool and connects with the same content database.
In an organization, we have 2 verticals Finance and BPO. If we need to share the same SharePoint web application between verticals without breaking the permissions! The best way is Extending Web Application.
In this article, we are going to learn how to extend a web application in both
- SharePoint Central Administration
- PowerShell command
Follow the below steps to extend a web application in SharePoint 2013 through Central Administration.
Log-on to Application Server with a FARM administrator account. Select the required web application under Manage Web Applications. From SharePoint Central Administration -> Application Management -> Manage Web Applications.
Click on Extend option as part ribbon control to extend the web application
Provide all the details of a new extending web application in the model dialogue window.
Note: In this model dialogue window do can’t see the below option which you see while creating a new web application as they carry forward from the original Web Application.
- Database server name
- Failover DB server name
- Application services
Once you provide all the details click on OK at the end of model dialogue window to create the extended web application.
Follow the below steps to extend the SharePoint 2013 web application using PowerShell commands.
Log-On to the Application server with a FARM administrator account
Open SharePoint 2013 Management Shell with a FARM administrator account
Run the below command to extend the desired web application
$ap = New-SPAuthenticationProvider -ASPNETRoleProviderName roleprovidername -ASPNETMembershipProvider membershipprovidername Get-SPWebApplication -Identity <Existing Web Application> | New-SPWebApplicationExtension -Name <Web Application Name> -HostHeader <HostHeader> -Zone <Zone> -URL <URL> -Port <Port> -AuthenticationProvider $ap Parameters: <Name> is the name of the new IIS web site in the web application. – Mandatory <HostHeader> is the hostname assigned to this zone of the web application. – Optional <Zone> is the zone with which this new extension is to be associated. – Mandatory <URL> is the public URL for this web application zone. – Mandatory <Port> is the port on which this zone of the web application can be accessed. – Mandatory
$ap = New-SPAuthenticationProvider -ASPNETRoleProviderName roleprovidername -ASPNETMembershipProvider membershipprovidername Get-SPWebApplication -Identity http://contoso.sales.com | New-SPWebApplicationExtension -Name IntranetSite -Zone Intranet -URL http://intranet.conoso.sales.com -Port 9876 -AuthenticationProvider $ap
Let us see, how to delete hidden web applications using PowerShell in SharePoint 2013/2016/2019.
While creating “Power Pivot Service Application” I have encountered the below error message, but I couldn’t be able to see the application pool as part IIS physically. The error comes as:
Sorry, something went wrong.
An object of the type Microsoft.SharePoint.Administration.SPLisWebServiceApplicationPool named “Power Pivot Service Application” already exists under the parent Microsoft.SharePoint.Administration.SPLisWebServiceSettings names “SharePoint Web Services”. Rename your object or delete the existing object.
Though we can’t see the application entry as part of Application Pools.
Delete Hidden Web Application in SharePoint 2013 using PowerShell
We should say thank to Microsoft for providing the PowerShell to delete the hidden Application pools.
Here are the commands for the same:
To list all the hidden Application pool(s):
Delete the Application Pool(s)
Remove-SPServiceApplicationPool -Identity ""
Examples / Output:
Once the application pool is deleted we can create the application pool with the same name. This is how we can delete web application in SharePoint using PowerShell.
You may like following SharePoint PowerShell tutorials:
- Bulk SharePoint Online Site Collection Creation using PowerShell
- 3 Different ways to Change Site Collection URL in SharePoint using PowerShell
- SharePoint 2013/2016: Get all ListTemplates from Site collection using PowerShell
- SharePoint BCS step by step
- PowerShell read all files from folder and subfolder
- How to upload files to SharePoint using PowerShell
- How to Change SharePoint Site Logo + PowerShell
- Display warning message in SharePoint site using PowerShell
In this SharePoint tutorial we learned, how to create a web application in SharePoint using PowerShell, also we saw how to create a site collection using PowerShell in SharePoint 2013/2016/2019.
I am Krishna.Vandanapu a SharePoint architect working in IT from last 13+ years, I worked in SharePoint 2007, 2010, 2013, 2016 and Office 365. I have extensive hands on experience in customizing SharePoint sites from end to end. Expertise in SharePoint migration tools like Sharegate, Doc Ave and Metalogix. Migrated SharePoint sites from SharePoint 2007 to 2010 and 2010 to 2013 several times seamlessly. Implementing CSOM with Microsoft best practices. Spent quality time in configuring SharePoint application services like User Profile, Search, Managed Meta data services etc. Now exploring SharePoint Framework and SharePoint 2019