While using multiple IIS servers in a Load Balanced Environment, it will be a lot of work to create all your website twice with the same settings on each webserver.ย In this scenario, it will create more critical to create a large number of binding for each server, so there is possible to export and import your configuration from one webserver to the other by using the command.
Executed and Tested Version
OS : Windows 10
IIS : 10.0.15063.0
To Export the website/IIS Bindings:
Macking backup of IIS configuration is as simple as copying the directory into a backup directory, so you don’t need anything special to do it.ย ย Just execute the below command in the Command prompt to make the backup copy in “C” drive with the file name Import_ProdBindings.xml
%windir%\system32\inetsrv\appcmd list site /config /xml > C:\Import_ProdBindings.xml
To Import the website/IIS Bindings:
As like Backup, it very simple to add the config to the IIS by using below command.
%windir%\system32\inetsrv\appcmd add site /in < C:\Import_ProdBindings.xml
OUTPUT:
Error :
I had faced the below error while exporting the config to the IIS. This error is due to the presence of “Default Web Site” in the targeted IIS.ย So you can delete the existing one before executing the new config OR you can change the name of “Default Web Site” in the config and start the import from backup.
Pretty easy, eh?ย Except for the dirty little secret everyone knows…remembering to do a backup before starting the Import!ย
“ERROR ( message:Failed to add duplicate collection element “Default Web Site”. )”
sure, thanks
I can verify that this works perfectly on Windows Server 2012, Windows Server 2019 and Windows 11 as well.