Adding New Web Applications

Using PowerShell to create new web applications with the IIS PowerShell Snap-In is incredibly easy. Just use New-WebApplication and specify

  • Site : Site to put it under
  • Physical Path : The directory path to the folder where the application will reside
  • Application Pool : The application pool running the web application
  • Name : The name of the application (what appears in the URL)

The physical path, application pool and site must be in place before running the cmdlet. It won’t create them automatically and will fail the install if they aren’t present. Conveniently, there are cmdlets to handle creating these as well:

Creating a new directory:

Creating an application pool:

Ne App Pool PowerShell

App Pool IIS

Creating a new site:

powershell created site

IIS Site

PowerShell doesn’t let you customize much during the default install (Restart schedules, application pool user, etc.), but it is easy to modify them after creation. Use the Set-ItemProperty (Alternatively, you can use Get-ItemProperty to look at the configuration values in IIS).

Unless you specify the Force parameter, old web applications won’t be overwritten by new ones. In order to test them before making the update specify the conditional using Test-Path:

Removing a web application is just as easy as creating one too. Just provide the name of the web application and the site it runs under:

Leave a Reply