Sunday, January 24, 2021

PowerShell script for creating web application in Sharepoint

In this blog post we will use PowerShell script for creating new web application in SharePoint. We can create web application from SharePoint central admin site as well, this is another way of creating the web application.

Note: Before going through the please go through my first post in power shell series which convers how to use PS scripts.

Below is the script for creating the application, here 1st script refers to generic script where you can replace with your own value as per requirement.

New-SPWebApplication –ApplicationPool <Application pool name> -Name <Web app name> -ApplicationPoolAccount <service account for the application pool> -Port <port number>

Below is the sample script for creating web app by internal host header with sharepoint.blogspot.com and public url with http://www.blogspot.com 

New-SPWebApplication -Name "BlogSite" -Port 80 -HostHeader sharepoint.blogspot.com -URL "http://www.blogspot.com" -ApplicationPool "SharepointBlogspot" -ApplicationPoolAccount (Get-SPManagedAccount "blogspot\spadmin")

We can create web application with claim based authentication enabled for that we need to use below script.

$authprovider = New-SPAuthenticationProvider
New-SPWebApplication -Name "BlogSite" -Port 443 -URL "https://www.blogspot.com" -ApplicaitonPool "SharepointBlogSpot" -ApplicationPoolAccount (Get-SPManagedAccount "blogspot\spadmin") -AuthenticationProvider $authprovider -SecureScoketLayer

No comments:

Post a Comment