Exporting & Importing App Pools and Websites configuration between multiple IIS instances

Exporting & Importing App Pools and Websites configuration between multiple IIS instances

One of the most boring things to do while configuring multiple web server nodes (cluster, server farm or other load balanced environments) is having to setup the entire website configuration tree in each IIS instance. Not to mention Application Pools, which are often a pain to configure properly.

Luckily enough, starting from IIS7+, there's a nice command-line utility called appcmd who can effectively export the entire IIS websites & app pools configuration in xml format and also import these same xml into another IIS instance. Let's see how we can do this.

Export the Application Pools

The first thing you have to do is to export/import the application pools, since they will most likely be used in your web sites and you won't be able to import those without having their relevant app pool into place. Here's the command-line:

This command will export all your application pools - including the default ones. You'll need to remove those, as they will most likely be in your target IIS instance with the same name and therefore they will raise a duplicate name error, blocking the whole import. In order to avoid that, open the newly created apppools.xml  file and remove the default ones such as:

  • DefaultAppPool
  • Classic .NET AppPool
  • .NET v2.0
  • .NET v2.0 Classic
  • .NET v4.5
  • .NET v4.5 Classic

... And also each one that's already present in your target. If you forget one, don't worry - you'll figure it out when you'll try to run the import procedure, which won't work.

Import the Application Pools

Copy the apppools.xml  file to your target webserver and run the following command:


Each and every Application Pool mentioned in the xml file will be created on your target IIS instance.

Export the Websites

Right after the App Pools you can copy your website configuration. Open up again a command-line console on your source webserver and type in the following command:

Again, you'll have to remove the default websites -  you'll most likely have only one default website, which is Default Website - as well as any other website you don't want to copy and/or is already existing on the target IIS instance, otherwise the import command won't work.

Import the Websites

Just like you did with the App Pools file, copy the websites.xml  file to your target webserver and run the following command:


Export/Import a single App Pool or Website

These commands can also be used to export/import a single application pool or a specific website. You just have to add their identifying name to the command-line, such as:

Export a specific Application Pool


Import a specific Application Pool


Export a specific Website


Import a specific Website


That's all for now. Happy coding!


About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

11 Comments on “Exporting & Importing App Pools and Websites configuration between multiple IIS instances”

  1. I got the app pools to import successfully, but when I attempt to import the websites, I get:

    C:>%windir%system32inetsrvappcmd add site /in < D:medtestmywebsite1.xml
    ERROR ( hresult:8007000d, message:Command execution failed.
    The data is invalid.
    I changed the physical paths to match the directory structure, but still receive this error.
    Please advise.

    1. Me too.. Can’t find anything anywhere on this.. it’s the final step keeping me from running server migrations to new web farms!

  2. For anyone else coming along, I had to fix the quotes in these snipits, they copy and pasted oddly. “CustomAppPool”

  3. Hello Rayan,
    I tried to execute the import script to import all app pools from cmd promt running in administrator mode but still im getting error as “Access Denied”. can you help me out.`

    1. Hello Vivek,

      I got this error some months ago: it was due to one of the %SystemRoot%\System32\inetsrv\config\ config files (those ending in .config) being read-only on the target machine.

      It’s most likely a read-only issue.

  4. Valid for IIS 8.5 Windows Server 2012 R2 / Windows 8.1 to
    IIS 10.0 Windows Server 2016 / Windows 10 ?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.