IIS Server and Site Comparison with Web Deploy

 

This post is leveraging the information in this post https://blogs.iis.net/msdeploy/archive/2008/02/02/using-ms-deploy-to-compare-sites-or-see-what-components-your-site-uses.aspx 

Housekeeping:

Source server = Server sending the web files

Target server = Server receiving the files (new server)

For these examples, the Source server IP is 10.0.0.11 and the Target server is 10.0.0.12.

IIS Configuration:

Customers not using Shared Configuration feature in IIS can experience situations with the configuration between servers in a farm becoming out of sync and this can introduce complexity when troubleshooting issues in the environment. This is prevalent with intermittent issues in a load balanced environment as the site will function correctly for one user and the second user would be sent to the second serve in a round robin configuration and the site is not exhibiting the same behavior since the configuration is different on the second server.

When completing a comparison, start from the gold server, or server with the correct configuration. This will provide a baseline to use against the other servers. Recommended to always start the comparison from the same server.

Compare ApplicationHost.config Files:

The fastest method is to do file level comparison between the server’s applicationHost.config files. Obtain applicationHost.config file from each server in the farm and use a file comparison utility such as BeyondCompare or WinDiff and find the differences make the adjustments to the servers in the next maintenance window.

Web Deploy Method:

The provider to use for the comparison is the appHostConfig since the comparison is completed on the website’s configuration (bindings, app pools, certs, etc..). This method will also generate a list of file level differences between the sites and will require a review of just the IIS configuration differences. The –whatif command outputs the differences into a text file for review. The text file can be omitted and by removing the pipe command and the output will display in the command window.

msdeploy.exe -verb:sync -source:appHostConfig="Contoso.com",computername=10.0.0.11 -dest:appHostConfig="Contoso.com",computername=10.0.0.12 -whatif > c:\_WebDeploy\WebSiteDiff.txt

To automate this process, create a list of servers in a text file or PowerShell array and substitute the compuername= with the variable and rename the output. I will try to post a PowerShell example in a future update to this post.

Web Site Content Comparison:

Folder Comparison tool:

The utility Beyond Compare has the ability to compare directories and show the differences. Copy the files from the gold server to the server missing the correct version of the files.

Web Deploy:

The Web Deploy provider to use depends on the level in IIS being compared. For instance, it is possible to do a comparison between web site level or moving down the object hierarchy, comparing specific folders. The web site level comparison will compare all files in all directories for the web site.

Web Server Difference– Highest Level

To see all of the differences between the servers, use the webserver source provider and output to a text file:

msdeploy.exe -verb:sync -source:webServer –dest:webServer,computername=10.0.0.12 -whatif > c:\_WebDeploy\WebServerDiff.txt

Site Level Difference:

Using the contentPath source provider, this script shows the difference between the site’s content:

Msdeploy.exe -verb:sync -source:contentPath="Contoso.com" -dest:contentPath,computername=10.0.0.12 –whatif > c:\_WebDeploy\WebSiteDiff.txt

Folder Level Difference:

If you want to compare just a folder under a site, use the dirPath for the source provider. This is the fastest method in Web Deploy for a differencing report:

Msdeploy.exe -verb:sync –source:dirPath="c:\inetput\websites\contoso\staticfiles" -dest:contentPath="c:\inetput\websites\contoso\staticfiles",computername=10.0.0.12 –whatif > c:\_WebDeploy\ContosoFolderDiff.txt