Configuring IIS using console

Photo by Arget on Unsplash

Setup of new development environment is a very time consuming operation each time (no matter what the reason is: moving to new project, OS reinstall, hardware update). Tools are getting better and better each day, now having fast internet connection and package managers, like NuGet and NPM we waste less time on installing all the required dependencies. But today I want to dig into small, but very easy-to-automate part of development environment setup part – adding and configuring site on IIS.

You can think, that it’s a deal of 5 minutes to add a new site to IIS and to change a couple of required options. If you already did it before – of course. But what if you need to help 2-3 other developers or newcomers? What if someone from QA group will miss some options and you’ll not find it really quickly?

In such kind of situation I prefer to reduce the human factor as much as possible. And it’s the place, where console tools can help a lot.

To work with IIS configuration from console you should use appcmd tool. Unfortunately this tool is not well-documented in my opinion. Basic documentation is quite good, but there are a lot parameters, which can be used and not all of them described in the documentation.

appcmd default info

To start working with the tool I recommend to use this command: %systemroot%\system32\inetsrv\appcmd – it will put you to the right place. Buy typing this command directly you should see something like on the screenshot below:

There dozen of objects as you can see and couple of commands (basically it’s verb like add or remove). But as far as we are talking about development environment setup you’ll most likely will require only add command and two objects:

  • SITE;

To receive some guidelines you should use /? symbols (as usual). So it will look like this:

# This one for adding sites:
%systemroot%\system32\inetsrv\appcmd add site /?
# This one for adding application pools:
%systemroot%\system32\inetsrv\appcmd add apppool /?

Unfortunately this command will not give you all required information, just a generic idea. But, if you’ll add value for required parameter you get the full list of available parameters (without values, which can be used, but anyway it’s already some starting point):

# This one for getting full list of parameters for adding site:
%systemroot%\system32\inetsrv\appcmd add site /name:test /?
# This one for getting full list of parameters for adding application pool:
%systemroot%\system32\inetsrv\appcmd add apppool /name:test /?

Here is the couple of properties I’ve changed for the purposes of my project (these all options for Application Pools only):

  1. managedRuntimeVersion. Possible values:
    1. v2.0;
    2. v4.0;
    3. Leave blank (no managed code option);
  2. enable32BitAppOnWin64. Possible values:
    1. true;
    2. false;
  3. managedPipelineMode. Possible values:
    1. Integrated;
    2. Classic;
  4. processModel.identityType. Possible values:
    1. NetworkService;
    2. LocalSystem;
    3. LocalService;

I didn’t find any way to get list of possible values from the application itself. If you’ll find – please, leave a comment, I’ll update this post to share this information.

2 thoughts on “Configuring IIS using console

    1. I used PowerShell only few times, so I’m not really familiar with the abilities, that it provides. Maybe at some point I need to stop using CMD and dig deeper into PowerShell


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s