How to Export and Import Sites and Application pools in IIS

I recently had to move a lot of sites and app pools from server 2008 (IIS 7) to server 2016 (IIS 10) and found the below very useful. One issue i found when exporting all the sites is if the destination already has a “Default Site” app pool the command will error out complain that the Default app pool already exists. So i had to delete all the app pools on the destination and then do the import. The same thing had to be done for sites but sure beats importing 50 sites and app pools manually.

APP POOL IMPORT / EXPORT

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

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

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

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

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

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

To import a single website:
%windir%\system32\inetsrv\appcmd add site /in < c:\mywebsite.xml

This entry was posted in Scripting and tagged , . Bookmark the permalink.

Leave a Reply

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