title: Assigning return value to variable breaks recursion
body: <p>I'm working on a recursive function to compare two JSON objects and ran into a strange issue. My recursion works fine... until I assign the result of the recursive call to a variable. If I just make the function call, the recursion works, and all members are iterated. When the assignment is present, recursion breaks and only the first level of the object is iterated.</p>
  <p>(Line with arrow indicates recursive call)</p>
  <p>Is there some reason this doesn't work?</p>
  <pre><code>function Compare-Objects() {
    [CmdletBinding()]
    Param(
      $Current,
      $Expected
    )
    foreach ($Property in $Expected.PSObject.Properties) {
      $Property.Name + &quot; : &quot; + $Property.TypeNameOfValue
      if ($Property.TypeNameOfValue -like &quot;*PSCustomObject&quot;) {
  -&gt;    $Match = Compare-Objects -Current $Current.$($Property.Name) -Expected $Expected.$($Property.Name)
      }
      elseif ($Property.TypeNameOfValue -like &quot;*Object[[][]]&quot;){
        # Compare-Arrays -Current $Current.$($Property.Name) -Expected $Expected.$($Property.Name)
      }
      else {
        if ($Property.Value -like &quot;*enums*&quot;) {
          $Expected.$($Property.Name) = Invoke-Expression -Command $Expected.$($Property.Name)
        }
        if ($Current.$($Property.Name) -ne $Expected.$($Property.Name)) {
          return $false
        }
      }
    }
    return $true
  }
  </code></pre>