Need help in automating the scan/comparison of XML files thoroughlyRSS

4 replies

Last post Jun 24, 2019 02:32 PM by Amy100

  • 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)

    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:

    <div>

    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>

    Amy

  • Re: Need help in automating the scan/comparison of XML files thoroughly

    Jun 21, 2019 02:43 AM|Jalpa Panchal|LINK

    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

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Need help in automating the scan/comparison of XML files thoroughly

    Jun 21, 2019 02:02 PM|Amy100|LINK

    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!

  • Re: Need help in automating the scan/comparison of XML files thoroughly

    Jun 24, 2019 07:47 AM|Jalpa Panchal|LINK

    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.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Need help in automating the scan/comparison of XML files thoroughly

    Jun 24, 2019 02:32 PM|Amy100|LINK

    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.