locked
Need help in automating the scan/comparison of XML files thoroughly RRS feed

  • Question

  • User-369761015 posted

    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)

    Output:

    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! :)

    Thanks again,

    Amy

    Thursday, June 20, 2019 5:05 PM

All replies

  • User-848649084 posted

    Hi,

    It's more like a solution delivery and IIS forum does not support a solution delivery. but from our point of view, for this kind of requirement, you should use git to manage the change not write a script by yourself.

    Regards,

    Jalpa

    Friday, June 21, 2019 2:43 AM
  • User-369761015 posted

    Thanks. But would appreciate if you could pls. provide me some direction about any existing public GIT repo which may have these changes implemented? 

    Thanks again!

    Friday, June 21, 2019 2:02 PM
  • User-848649084 posted

    I think you misunderstood the suggestion. 

    I am suggesting you that while you try to commit a change or merge a branch, git will show you the difference.

    e.g. you changed web.config and you want to merge the new web.config to the old one, you can add reviewers to this change and the reviewers would verify if the changes are valid.

    it's not some repo that already has this kind of feature.

    Monday, June 24, 2019 7:47 AM
  • User-369761015 posted

    Yes, that's what our team is already doing it manually but the requirement is to make this type of validation process automated instead of manually selecting already merged commits/revisions etc. Anyhow, if the solution is not available on this forum then I'll explore around in any other forums and see what info they have about it.

    Anyways, thanks for your help, appreciated.

    Monday, June 24, 2019 2:32 PM