Exporting and Importing Sites and App Pools from IIS 7 and 7.5

When using multiple IIS server in a Load Balanced Environment it will  be alot of work to create all your website twice with the same settings on each webserver. Therefor it is possible to export and import your configuration from one webserver to the other. This will also be usefull when your upgrading from IIS 7 (Windows Server 2008) to IIS 7.5 (Windows Server 2008 R2).

When you create a website in IIS 7 or 7.5 a unique application pool will also be created and used by this website, that’s why you need to import these application pools first on the second webserver before importing the website(s).

To Export the Application Pools on IIS 7 :
%windir%\system32\inetsrv\appcmd list apppool /config /xml > c:\apppools.xml

This will export all the application pools on your webserver, therefor you need to edit the apppools.xml and remove the application that you do not need to import for example:

  • DefaultAppPool
  • Classic .NET AppPool
  • SecurityTokenServiceApplicationPool

And other apppools that already exist on the second webserver, appcmd doesn’t skip already existing apppools, it just quit’s and doesn’t import any.

To import the Application Pools:
%windir%\system32\inetsrv\appcmd add apppool /in < c:\apppools.xml

All the AppPools in the xml will be created on your second webserver.

To Export all your website:
%windir%\system32\inetsrv\appcmd list site /config /xml > c:\sites.xml

This will export all the websites on your webserver, therefor you need to edit the sites.xml and remove the websites that you do not need to import for example:

  • Default Website

And all other websites that already exist on the second webserver.

To Import the website:
%windir%\system32\inetsrv\appcmd add site /in < c:\sites.xml

It’s also possible to export a single website or application pool all you need to do is add the name of the Application Pool or Website to the command line:

To export/import a single application pool:
%windir%\system32\inetsrv\appcmd list apppool “MyAppPool” /config /xml > c:\myapppool.xml

%windir%\system32\inetsrv\appcmd add apppool /in < c:\myapppool.xml

To export/import a single website:
%windir%\system32\inetsrv\appcmd list site “MyWebsite” /config /xml > c:\mywebsite.xml

%windir%\system32\inetsrv\appcmd add site /in < c:\mywebsite.xml

73 comments on “Exporting and Importing Sites and App Pools from IIS 7 and 7.5”

  1. Dan says:

    This is great. I would have loved a way to do all this from the GUI. Would have loved to just export out the XML, and Imported it on another server to create the specific site and the specific app pool.

  2. Eric says:

    I have tried a number of times to export a single website configuration and import it on another machine. The XML output from the command above looks correct. However, when I try to import the XM I always get:

    ERROR ( hresult:8007000d, message:Command execution failed.The data is invalid. )

    Any help would be appreciated.

    1. Michael says:

      Hi Eric,

      Sorry for the late response, I was on my holiday. I couldn’t replicate the error, but i saw my XML was empty when i used the export for a single website command. If you use %windir%\system32\inetsrv\appcmd list site /config /xml > c:\mywebsite.xml the xml will contain all websites and you can edit the xml and trow away all the sites you don’t need.

      Hope this will help you.


      1. Imran Aslam says:

        I have same issue occur but i have exported all sites so when we import into other server it’s come.However , when we import all app pools first so it is easily done from the xml file which we exported.

        So please guide me what will we do now for all sites.However , All sites in IIS in 2nd Server is empty now for the safe side.

      2. Imran Aslam says:

        I have same issue occur but i have exported all sites so when we import into other server it’s come.However , when we import all app pools first so it is easily done from the xml file which we exported.

        So please guide me what will we do now for all sites.However , All sites in IIS in 2nd Server is empty now for the safe side.

        1. Vinnie says:

          I Have identically issue but in my source server I had Advanced Logs installed and in the New server don´t have, I edited my XML and remove the instructions and solve this mistake. If you have any feature enable in source or install in the new or remove the instructions on XML.

          1. mknopf says:

            removing the AdvancedLogging node resolved the issue for me as well, thank you so much!

    2. Ben says:

      Very late response but if anyone else has this issue, for me it was because I had an unclosed string in the config file which had obviously stuck after removing the default app pools from the config. Worth checking you don’t have anything similar.

    3. Carlos says:

      This issue is because you have one extra configuration in the source server that the destination server doesn’t have. In my case I have the extra line:
      Make an export file for each server and compare the lines.

  3. Alexander says:

    Thank you very much for this, it saved me a lot of time. A few notes:

    1) I had to run the commandline as Administrator, else I received an error about permissions.
    2) Authentication settings (anonymous with specific account+password in my case) on the website were not transferred for some reason, so I had to set them again.

  4. Brian Cooperider says:

    When importing the websites I get the message “failed to add Duplicate collection element “default Web Site” I removed the following lines:

    What lines do I need to remove to not duplicate the default website?

    1. Michael says:

      Hi Brian,

      Remove the first part in the exported XML

      up to

    2. Alexander says:

      Additionally, if you’re exporting/importing from and to another webserver that’s not completely identical, you might get clashing ID’s on the sites, and hence the “duplicate” error. Hack the XML accordingly so they don’t clash.

  5. Brian Cooperider says:

    Thanks Mike,

    I actually got it working the other day by deleting the default website. Went to do a second machine the same way today and it’s only importing the default and not the rest. I can’t figure out why.

  6. Robert says:

    Here is the proper syntax to export an individual site:

    appcmd list SITE /site.name:SITENAME /config /xml > c:\SITENAME.xml

    1. liz says:

      i tried your syntaxt for exporting an individual site. It does work. It just produces this:

  7. MKZA says:

    Great BUT I still cannot fathom why after so many years there is not a simple right click export from IIS manager ?? Microsoft continually misses the boat in providing simple time saving functionality, stuff we actually need.

  8. Sharad K Rathi says:

    Can you tell me how can transfer IIS FTP Accounts & Windows User Accounts from one server to other server?

    With Regards
    Sharad K Rathi

    1. Michael says:

      Hello Sharad,

      The local windows users can be migrated with this document : http://technet.microsoft.com/nl-nl/library/dd379531(v=ws.10).aspx

  9. kutegirl says:

    What about if Im exporting to another IIS server that already has other sites and configuration files defined. Will the import erase the existing configurations on the second server or will it merge the old with the new one?

    1. Michael says:


      When you export the sites there will be an XML with al the configuration in it. When you have a site on the server where you want to import which has the same name, it will be overwritten. You can edit the XML and change the naming, or take out the config for one or more sites before importing.



  10. Hugh Caldwell says:

    Just wanted to mention that these command have to be run in DOS window and not from Powershell. I’ve gotten used to using PS so I ran the export command from a PS window but since PS doesn’t recognize ‘<' I tried to run the import commands from a DOS prompt and got malformed XML erros. Running the export from a DOS prompt resolved this error.

  11. krishnakumar K says:

    Thanks a lot.. it saved a lot of time

  12. Diego says:

    great post!
    I have the same problem that Hugh Caldwell said.
    That would be a good to export and import configurations with PSExec but the problem is that PS doesn’t recognize ‘’.
    For example: C:\PS\psexec.exe -accepteula \\server -u user -p password %windir%\system32\inetsrv\appcmd.exe ADD SITE /IN < \\server\share\MySite.xml

    this NOT work
    Can you help me?

    1. Michael says:

      Hi Diego,

      I guess this is a short coming of PSExec it just hangs when you execute the command.

      I can’t help you with this one.


      Best regards,


  13. James Bollam says:

    Hi, deleted the default site from IIS (yes I know daft), I don’t want to rebuild my server (server1).

    if I build another server (server2) on another server Could I use this method to move the default site from server2 to server1

    1. Michael says:

      Hi Eddie,

      You can use this to re-create the default website, on the other hand you could just create an new website and point it to c:\inetpub\wwwroot this will have the same result.

  14. itismeap says:

    The scary thing about this export command is that the passwords for any service accounts are exposed in plain text!!! That is very suprising….

    1. Michael says:

      That’s not nice, I’m affraid I cannot change that.

      As long as everyone knows it now and removes the export file after usage it will be OK I guess.

      Thanks for sharing your observation.

  15. Gireesh says:

    I have 10 websites and 10 application pools in IIS. As per the above commads, We can Export and Import All Config at a time. But i want to export only 5 websites and 5 application pools by using a single command. is this possible?. If it is possible Please let me know how to export.

    Thanks in Advance.


    1. Michael says:

      Hi Gireesh,

      It is possible to export/import multiple individual site in a “single” command by seperating the command with a pipe |

      for example :

      appcmd list site site1 /config /xml > c:\site1.xml | appcmd list site site2 /config /xml > c:\site2.xml

      This will export 2 sites named site1 and site2 into 2 xml files, you can do the same for apppool’s.



  16. Daniel says:

    ( (( Thanks
    \ =\ For
    __\_ `-\ Posting
    (____))( \—- This!
    (____)) _


  17. Shashi says:

    Below commands are giving no output while exporting

    %windir%\system32\inetsrv\appcmd list site “MyWebsite” /config /xml > c:\mywebsite.xml

    appcmd list SITE /site.name:SITENAME /config /xml > c:\SITENAME.xml

    please help me!!!

    1. Michael says:


      You need to change the “MyWebsite” to the name of your website.


      %windir%\system32\inetsrv\appcmd list site “Default Web Site” /config /xml > c:\mywebsite.xml



  18. Babu Ashok says:

    Very useful post.. Saved lots of time and effort in replicating site settings.

  19. Snark says:

    Merci, thanks, very helpfull for me.

    But export a single website didn’t work, even with right site name, I had to export full, purge in xml not needed site, then it’s ok.

    %windir%\system32\inetsrv\appcmd list site “DefaultPage” /config /xml > c:\mywebsite.xml

    Do not work for me on W2k8R2 (quite empty file).

    appcmd list SITE /site.name:SITENAME /config /xml > c:\SITENAME.xml
    => not tested, I have a workaround solution

  20. Luis Rocha says:

    Thanks for the great post! Just in case you want to use the import commands with powershell, you could use:

    gc .\apppools.xml | C:\Windows\System32\inetsrv\appcmd.exe add apppool /in


    gc .\sites.xml | C:\Windows\System32\inetsrv\appcmd.exe add site /in

  21. Eric DUncan says:

    Thanks for this post.

    NOTE: It does not export the SSL binding settings. You still have to do this manually, though this saved a whole lotta time binding dozens of IPs and ports!

  22. Basavaraj says:

    Really nice and appriciated.. thanks

  23. Jaykumar says:

    Very good article Michael

  24. prashant says:

    really helpful information saved my lots of time while re-configuring to new server

  25. Adam Senour says:

    As others have said, this is an outstanding article and a real timesaver.

    One thing I’d like to add to it, though…if you have any kind of duplicate issue, the sites/app pools that you add prior to the duplicate issue won’t get added. Therefore, you’ll need to rerun the commands once you remove the duplicate site/app pool. Don’t edit anything else; just the duplicate site/app pool.

    Anyway, much appreciated!

  26. Steve says:

    What about exporting a virtual directory instead of the whole website. Unfortunately my company really uses virtual directories when they should be creating separate websites.

    I don’t want to clobber or propagate changes to any other virtual directories that are not mine on the other server.

  27. Miki says:

    Is this going to work with our asp.net apps which we need to move from IIS 7.5 (Windows Server 2008 R2) to IIS 8.5 (Windows Server 2012 R2) ?

  28. krishna says:

    we want to import or export sites and apppools from one computer to another computer at a time is it possible?

  29. krishna says:

    sorry for the typo. another means multiple computers is it possible?

    1. Michael says:

      Hello Krishna,

      The export generates xml files, the can be imported on as many computers you wish.

  30. Rajesh Kannan says:


    We are planning to migrate the IIS 7 & IIS 7.5 to IIS 8 .
    so we can use the same export and import command for the same.
    Note : Migrating from Windows 2008 to Windows 2012 OS

    Let me know ,If you have any other command for export & import command for the same.

    Rajesh Kannan R

    1. Michael says:

      Hi, this methode can be used for this upgrade scenario

      1. Rajesh Kannan says:

        I am trting to Import the XML file into new destination servre , but getting below error. Kindly check and help ASAP.

        C:\Windows\System32\inetsrv>appcmd.exe add site /in < C:\Test.xml
        ERROR ( hresult:8007000d, message:Command execution failed.
        The data is invalid.

        New Destination server is Windows 2012 OS + IIS 8.5

        Source server is Windows 2008 OS + IIS 7.5

        Rajesh Kannan R

  31. Rajesh Kannan Rajendran says:

    Hello Michael,

    I need to migrate the My IIS 6.0 Version sites in to IIS 8.5 Version. Kindly help me how to migrate and share the steps also.

    Note : we don’t have appcmd in IIS 6.0 version, so i cannot export the apppool and site in same.

    Rajesh Kannan

  32. Robert says:

    Sorry, this is working now for an individual site:

    %windir%\system32\inetsrv\appcmd list SITE /site.name:SITENAME /config /metadata /xml > d:\SITENAME.xml

  33. Aaron van de Sande says:

    For single site export the examples in the article work but DO NOT use double quotes.

  34. Hari says:

    Great post. Saved me a lot of time.

  35. Walmart_IT says:

    Use this syntax to export a single file with all content (imagine a site named “wordpress” and replace that accordingly with your site name instead: “%windir%\system32\inetsrv\appcmd list SITE /site.name:wordpress /config:* /metadata /xml /debug > C:\folder\wordpress.xml”

  36. Walmart_IT says:

    Use this syntax to export a single site with all content (imagine a site named “wordpress” and replace that accordingly with your site name instead:

    “%windir%\system32\inetsrv\appcmd list SITE /site.name:wordpress /config:* /metadata /xml /debug > C:\folder\wordpress.xml”

  37. Imran Aslam says:

    I have export all sites in xml from Server1 and the Server2 is already have some sites and its App pools so when we import Server1 xml exportrd file to Server2.

    It is not allowing to do this.

  38. Basavaraj K says:

    Thanks Its worked for me…

  39. Basavaraj K says:

    It worked for Me… Thank you.

  40. Karri Srikanth says:

    Really nice and Good article.

    Thanks a lot.

  41. Murray says:

    Note: If your target has existing sites you may need to re-set all the IDs in your xml so they don’t clash with existing IDs

  42. Manny says:


    I resolved the issue. The problem was the authorization rules don’t export.


    I used the following command to add allow USERS and Read/Write

    appcmd.exe set config “MYWEBSITE” -section:system.ftpServer/security/authorization /+”[accessType=’Allow’,roles=’Users’,permissions=’Read, Write’]” /commit:apphost

    All good now!!!

  43. Mohit Mishra says:

    Hi I am getting following error:-
    ERROR ( hresult:80070057, message:Failed to commit configuration changes.
    The parameter is incorrect.
    Please help me on this.

    1. Mohit Mishra says:

      I had run this command “appcmd add apppool /in <c:\apppools.xml"

  44. Pam says:

    What would I need to change if the websites are not stored in the C”\windir\system32\inetsrv\ directory? For example, if they are placed in C:\web or C:\HostingSpaces? Sorry, I don’t normally do this stuff, but it’s been dumped in my lap do to the loss of my husband and I need to get a list of the websites currently in IIS so I can pass the list on to someone that will be taking things over for me.

  45. Ronaldo says:

    Amazing, right in the point! Nicely done!

  46. Charlie Arehart says:

    I want to elaborate a bit on something that some people in the comments were trying to help with.

    Beware that when you do the import of a site or sites, you may get a “Failed to add duplicate collection element” error (even after deleting the default site as warned about above).

    The problem is that the export of the sites from the source server will have stored in the websites.xml the “id” of the site in IIS–as it was on THAT source server. But if you have defined any sites on the server you are importing TO, you may have sites that ALREADY use that ID. And THAT is the reason for the conflict (though the error does not make that clear). I experienced this and helped someone solve it.

    The solution is to go to IIS, choose “sites” (which will show all your sites on the right), and click the “id” column to sort that list by id. Now look at the largest number there. Let’s say it’s 7. We can tell the websites.xml file to have all the sites start with 10 (it’s not important that there “be no gaps” in the number. Such gaps can happen when you merely delete a site in the IIS UI.)

    So now go into the websites.xml file, and you will see that for each site, there are TWO references to the site “ID” (in the first couple of XML lines per site). Change those two references to use that next number, like 10. Then find the next site’s XML elements, and change its two site ID values to 11, and so on.

    Save the file, then try the import step again. That solved the problem for me.

Leave a Reply

Your email address will not be published. Required fields are marked *


Please enter the CAPTCHA text

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