Created
November 17, 2022 16:24
-
-
Save deadlydog/3b90245af3b4b233b1730df422c8668d to your computer and use it in GitHub Desktop.
Migrate IIS Apps And Configuration ToOther Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: This script will migrate all of the IIS Applications and Configuration from the local server to the destination server. | |
:: This script needs to be ran from the source server that has the IIS configuration that you want to migrate. | |
:: MsDeploy will often generate a lot of output, so it's best to remote desktop onto the server that you want to migrate, | |
:: rather than running this command via PowerShell Remoting, as it will take a very long time to pipe the output back to | |
:: your local machine. | |
:: The server you are syncing to must also have Web Deploy installed on it. You can download it from: | |
:: http://www.microsoft.com/en-ca/download/details.aspx?id=43717 | |
:: Be sure to do the "Complete" installation, not just the "Typical" so that the Web Deployment Agent Service gets installed. | |
:: To sync an individual IIS application pool and website, you can use the following, replacing the source apppoolconfig and apphostconfig names: | |
:: "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:apppoolconfig="[APP POOL NAME GOES HERE]" -dest:auto,computerName=%DestinationServerName% -disableSkipDirective:ConfigProtectedData | |
:: "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:apphostconfig="[WEBSITE NAME GOES HERE]" -dest:auto,computerName=%DestinationServerName% -disableSkipDirective:ConfigProtectedData | |
:: If you receive an error like: | |
:: Error: Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7) | |
:: Then you may need to sync the websites individually to find out which one is causing the problem. | |
:: Update the DestinationServerName variable to the name of the server to copy the IIS configuration to. | |
:: e.g. SET DestinationServerName=ServerName.MyDomain.com | |
SET DestinationServerName=REPLACE_THIS_WITH_SERVER_TO_SYNC_TO | |
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:webServer -dest:auto,computerName=%DestinationServerName% -disableSkipDirective:ConfigProtectedData | |
PAUSE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment