title: Recursively searching / comparing nested Hashtables?
body: <p>Let me start by apologising that the below data structure probably isn't written correctly. I dynamically created the hashes in the code and I'm not very good at trying to represent what gets created.</p>
  
  <pre><code>$Sailings= @{
      'Arrivals' = @{
          $DynamicKey_booking_Ref = @{
              'GoingTo' = 'Port1';
              'Scheduled' = '09:05';
              'Expected' = '10:09';
              'Status' = 'Delayed'
          }; 
      'Departures' = @{
          $DynamicKey_booking_Ref = @{
              'ArrivingFrom' = 'Port1';
              'Scheduled' = '09:05';
              'Expected' = '09:05';
              'Status' = 'OnTime'
          }; 
      }
  }
  </code></pre>
  
  <p>I typically access the data like this. (hopefully that confirm the structure I'm using):</p>
  
  <pre><code>$Sailings.Arrivals.PDH083.GoingTo which returns "Port1"
  $Sailings.Arrivals.PDH083.Scheduled which returns "09:05"
  </code></pre>
  
  <p>where PDH083 in this example is a dynamically created key based on a booking ref.</p>
  
  <p>What I am trying to do is compare this structure with another identical structure but with potentially different values. E.g. are these two elements the same?</p>
  
  <pre><code>$Sailings.Arrivals.PDH083.GoingTo =  "Port1"
  $Output.Arrivals.PDH083.GoingTo  = "Port5555"
  </code></pre>
  
  <p>If they're not the same capture the difference and the path/key that was different. Then report on them at the end. </p>
  
  <p>What I'm struggling to write is a recursive loop that can walk down to the last element and then compare it to the <code>$output</code>. While my hashes are fixed now, I'd like to allow for the possibility that more nested hashes might be added lower down at a later date. Is this something that can be done easily?</p>
  
  <p>I've used</p>
  
  <pre><code>($Sailings.Arrivals.keys | ? {$Output.Arrivals.keys -notcontains $_})
  </code></pre>
  
  <p>to show missing keys, but I just can't fathom a similar / efficient way of doing this for the values. I again can see I can use <code>.values</code> but it's still and element at a time.</p>