I am building another web server "web2", which must have the same configuration as web server "web1"
So after installing some software I need to edit the "web.config" on the "web2" server to match the one in the "web1" server
I am doing this from my laptop, so I copied both "web.config" files to my laptop running these commands:
$w1="web1.server.local"
$w2="web2.server.local"
$myCred=(Get-Credential -credential "myAD\myUser")
$file="C:\path\to\my\web.config"
Invoke-Command -ComputerName $w1 -Credential $myCred (Get-Content $args[0]) -ArgumentList $file | Set-content web1.txt
Invoke-Command -ComputerName $w2 -Credential $myCred (Get-Content $args[0]) -ArgumentList $file | Set-content web2.txt
Ok so now i have both "web.config" files from both servers named as: web1.txt and web2.txt
Here you can see a picture of the differences in the files (I got this using notepad++) as you can see there are only 4 differences. please take in note I trim the files to only have 42 lines each
Then I tried to compare both files using the "Compare-Object" cmdlet but I am not getting an accurate info:
PS C:\> Compare-Object (Get-Content .\web1.txt) (Get-Content .\web2.txt)
InputObject SideIndicator
----------- -------------
<=
<=
The weird part is that if I just replace "< ! - - " with " < ! - - a" the output changes to:
PS C:\> Compare-Object (Get-Content .\web1.txt) (Get-Content .\web2.txt)
InputObject SideIndicator
----------- -------------
<!-- =>
<!--a <=
<=
<=
and then if I change the " - - >" to " - - >b" this is the output:
PS C:\> Compare-Object (Get-Content .\web1.txt) (Get-Content .\web2.txt)
InputObject SideIndicator
----------- -------------
<!-- =>
--> =>
<!--a <=
-->b <=
<=
<=
I try checking the encoding of the files, creating them in UTF-8, I also remove a lot of chunks of the xml file, remove a lot of brackets (on both files) but it never shows the difference.
Is there something I am missing?
Why Compare-Object cant tell if a plain file has an extra " - - > " or " < ! - - "
As you can see in the following image, I did a select-string and in the web1.txt shown the line 11, but web2.txt didnot shown line 11, so those files are not the same.
Thank you!!!