I want to ask you a suggestion about how to proceed in migrating an entire IIS (version 8.5) in Windows Server 2012 R2 to IIS (version 10) on Windows Server 2019. I need a nearly automatic procedure because we have more than 500 sites on that server.
This is the spec for almost each web site:
A folder that contains the entire web site that I can easily replicate on the new server. Each folder has a web.config file that contains a db connection string (I can easily change that using a Python script over all the folders in the root of the web sites directory);
The IIS configuration and web sites that I can easily access through a power shell script like this:
Import-Module Webadministration
$sites = Get-ChildItem -Path IIS:\Sites
foreach($element in $sites){
$element
}
In which I see all the details of the web site. I know that an export tool exists in IIS, but I don't think it's possible to change the destination folder of the web site and also the bindings to adapt them to the new domain that I need to use on the new server.
At this point I'm a little stuck, because I cannot figure out how to proceed in a smart way. Ideally what I need is, for each web site I export the configuration, to create the web site on the destination IIS, update the reference folder of the web site to the location on the new server along with the binding (I need to change the domain) and start the site (in case of errors, show some sort of warning for manual inspection). Do you have any suggestion on how to proceed and make this process as automatic as possible? Also any scripts for reference will be really appreciated.
Using the WebAdministration module is safe but it's also slow.
As long as your target server is not live yet and you can play around with it, I would directly edit the
C:\Windows\System32\inetsrv\config\ApplicationHost.config
file.Copy the
<sites>
node from the config file on the old server to the config file on the new server.Also copy any
<location ...>
notes, usually at the end of the file.IIS 8.5 and IIS 10 are very similar and this should work. Always make a backup of the file you are changing.
Then you can just use Search and Replace of in the config file to change physical locations or bindings.