Comparing XML

Welcome Forums General PowerShell Q&A Comparing XML

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
6 months, 1 week ago.

  • Author
    Posts
  • #98452
    YCE

    Participant
    Points: 0
    Rank: Member

    I'm trying to compare 2 xml files where I create both using HP conrep. This is to check if all systems have the same bios setup. I read them doing [xml]$bios = get-content c:\dif.xml and further $reference = $bios.Conrep.Section|select name,'#text'. Similarly I go with $difference where I extract from [xml]$biosDif. I then compare both $reference and $difference running compare-object. Often I get no output which in my script sets the success value to true. However by chance I found that sometimes even though the contents of the 2 xmls will differ compare-object won't return anything. My $difference and $reference objects are of Selected.System.XML.XmlElement

  • #98460

    Participant
    Points: 0
    Rank: Member

    Try this:

    Compare-Object $(Get-Content c:\test1.xml) $(Get-Content c:\test2.xml) -includeequal

The topic ‘Comparing XML’ is closed to new replies.