View Complete Thread
  • Need help in automating the scan/comparison of XML files thoroughly

    Jun 20, 2019 05:05 PM|Amy100|LINK

    Good afternoon!

    I'm a very beginner on PS scripting and tried to apply some PS cmdlet these days. I've got a very recent project requirements to automate the XML files like 'Web.config' file comparison (just like how we usually do manually by using some tools like 'BeyondCompare' etc). I've tried to test out some scripting commands but unable to achieve the desired result. Here's what my scripting code looks like:

    This PowerShell script will find which app settings keys are missing from one config. file or the other

    [xml]$file1 = Get-Content "C:\Temp\Web.DEV.config"
    [xml]$file2 = Get-Content "C:\Temp\Web.PROD.config"
    Compare-Object ($file1.SelectNodes("//add[@key]") | Select-Object -ExpandProperty Key) ($file2.SelectNodes("//add[@key]")  | Select-Object -ExpandProperty Key)


    InputObject          SideIndicator
    -----------          -------------
    nonoamtestuserid     =>           

    I got an idea of how that indicator on the 'SideIndicator' column works but still unable to achieve the desired results as that cmdlet just scans and finds for the missing app setting keys only in either of those files. 

    But here's what the exact requirements are:


    The script should scan the whole "Web.config" file from the Development server (downloaded locally) with the "Web.config" file from the Production server (also downloaded locally) and compare them in a way that it should identify and display any differences in it (not just with app settings differences) and should prompt the developers to resolve those differences.  In an event of having no differences found, it should simply prompt to say something like 'Approve and proceed'. Resolving the differences I think should be done manually by the developers but the script needs to notify whether to approve any of those differences or to review them separately.

    I'd be really thankful for your precious time for helping me out! :)

    </div> <div></div> <div>Thanks again,</div>