How to Script / Automate IIS7 Configuration (without writing code)

I hear this question a lot in the, and thanks to Carlos and team's rocking Configuration Editor, figuring this out on your own is a breeze.  Here is how you can generate code for ANY IIS7 configuration change, without writing a line yourself.

1) download the IIS7 Administration Pack.  What, you don't have it already?  You're really missing out on some fantastic tools, including the Configuration Editor.  Learn more about the admin pack here  You can download x86 and x64 from

2) open "IIS Manager" and click on the "Configuration Editor" feature under the "Management" category:


3) Find the configuration section(s) you want to edit using the drop-down combo box, in this case isapiFilters:


4) use the configuration editor to make your change.  In this case, I'm editing a collection, which pops up a collection editor where I can add items to the isapiFilter list by clicking 'add' in the task pane.


5) once you're done making any configuration updates, click on the 'Generate Script' task in the main Config Editor window:


6) the script generator creates three ways of automating the configuration change you just made  C#, JavaScript (again the AHAdmin COM interface) and AppCmd.exe


7) Copy and Paste these changes into your own script / code and whoila, you've got sample code for making any IIS7 configuration change.

You may also want to read up on the IIS7 Administration APIs.  You can find a lot more information here:

Using Scripts to Automate Management

Managing IIS with the IIS 7.0 PowerShell Provider

1 Comment

  • using System;
    using System.Text;
    using Microsoft.Web.Administration;

    internal static class Sample {

    private static void Main() {

    using(ServerManager serverManager = new ServerManager()) {
    Configuration config = serverManager.GetWebConfiguration(null);

    ConfigurationSection appSettingsSection = config.GetSection("appSettings");

    ConfigurationElementCollection appSettingsCollection = appSettingsSection.GetCollection();


Comments have been disabled for this content.