Home » PowerShell » PowerShell Create New WebApplication in IIS Server

PowerShell Create New WebApplication in IIS Server

The PowerShell command used to create a new web application is `New-WebApplication`. The New-WebApplication command uses the Name parameter to specify the web application name, Site, PhysicalPath, and ApplicationPool parameters.

The New-WebApplication cmdlet is available in the PowerShell WebAdministration module. The syntax for the New-WebApplication command is given below.

New-WebApplication
   [-Site <String>]
   [-Name] <String>
   [-PhysicalPath <String>]
   [-ApplicationPool <String>]
   [-Force]
   [<CommonParameters>]

In this article, we will discuss how to create a new web application in the IIS server using the PowerShell New-WebApplication cmdlet.

How to Create a Web Application in an IIS Server

Use the New-WebApplication command to create a web application in the IIS server. The following PowerShell script creates a web application.

New-WebApplication -Name "MyApp" -Site "Default Web Site" -PhysicalPath "C:\MyApp\" -ApplicationPool "DefaultAppPool"

In the above PowerShell script, the New-WebApplication command creates a web application named “MyApp” on the “Default Web Site“. The web application files are physically stored in the location C:\MyApp folder, and the web application runs in the “DefaultAppPool” application pool.

The Name parameter in the command specifies the name of the web application that we want to create in the IIS server.

The PhysicalPath parameter parameter specifies the location of the web application files.

The Site parameter specifies the name of the site on which the New-WebApplication command creates an application.

The ApplicationPool parameter specifies the name of the application pool in which the new web application runs.

The output of the above PowerShell script creates a web application in the IIS server.

Conclusion

I hope the above article on how to create a web application in the IIS server using the New-WebApplication command is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Related Articles

Create a new website

Remove website

Get all websites and applications in IIS

Check IIS Status