title: PowerShell compare values of dictionaries
body: <p>I have two dictionaries which I need to compare. The logic behind this is that if the key from the second dictionary is found between the values of the first dictionary the value from the first one needs to be replaced by what the value from the second one contains.</p>
  
  <p>So in this example, the value 'MemberOf' in the FIRST dictionary should be replaced by the value of the key in the SECOND dictionary. I would like to mutate the value and not create a new dictionary/list.</p>
  
  <p>The solution should be able to run in PowerShell v2.</p>
  
  <pre><code>$base_properties = `
      @{
          'user' = `
              ('CN', 'MemberOf')
      }
  
  $expression_properties = `
      @{
          'MemberOf' = @{name='MemberOf';expression={$_.MemberOf -join ';'}}
      }
  </code></pre>
  
  <p>Final solution:</p>
  
  <pre><code>foreach ($prop_key in $base_properties.Keys) {
      foreach ($prop_name in $base_properties[$prop_key]) {
          if ($expression_properties.ContainsKey($prop_name)) {
              $index = $base_properties[$prop_key].IndexOf($prop_name)
              $base_properties[$prop_key][$index] = $expression_properties[$prop_name]
          }
      }
  }
  </code></pre>