IIS (Internet Information Services) is a web server created by Microsoft for Windows systems. As a system administrator we know that to manage IIS is easy from GUI. Some times we get tasks to create large number of websites under IIS or create site in IIS using windows batch script. This article will guide you to how to create Website and App Pool in IIS using command line.
Before using below commands, start the command prompt as administrator. So that you can get all privileges to make changes. After that navigate to C:WindowsSystem32inetsrv directory.
Create Website in IIS
For example we need to create a website named example.com with document root c:sitesexample.
> appcmd add site /name:example.com /id:1 /physicalPath:c:sitesexample /bindings:http/*:80:example.com
Create App Pool in IIS
IIS App Pool used for grouping of sites to use similar configuration settings or prevent to other application to use resources of one application by other application. Use one of below option as per your requirements
App Pool with Default Settings
Use following command to create App Pool with default settings of IIS.
> appcmd add apppool /name:Sales
App Pool with Specific Settings
If you want to use different settings for your App Pools, use command like below. Change managedRuntimeVersion as per your requirements v1.0, v1.1, v2.0 or v4.0.
> appcmd add apppool /name:Sales /managedRuntimeVersion:v2.0 /managedPipelineMode:Integrated > appcmd add apppool /name:Sales /managedRuntimeVersion:v2.0 /managedPipelineMode:Classic
Change App Pool of Website
If you want to change App Pool of any website. Use following command to change application pool of site example.com and set App Pool to Sales
> appcmd set site /site.name:example.com /[path='/'].applicationPool:Sales