title: PowerShell string format different behaviour within function
body: <p>While using powershell I struggle to build up a filename from two variables. When I originally creaded the powershell script, it was working fine. Now I have tried to move some repeatable steps into a function, but the string behaviour is different.</p>
  <p>MWE:</p>
  <pre><code>$topa = &quot;ABC&quot;
  $topb = &quot;XYZ&quot;
  
  function Test-Fun{
      param(
          $a, 
          $b
          )
      echo &quot;$($a)H$($b).csv&quot;
  }
  
  echo &quot;$($topa)H$($topb).csv&quot;
  
  Test-Fun($topa, $topb)
  </code></pre>
  <p>The output on my system is</p>
  <pre><code>ABCHXYZ.csv
  ABC XYZH.csv
  </code></pre>
  <p>Originally, I wanted to use an underscore instead of H and thought that is causing issues, but its not. What did I miss or rather what is the difference between string expansion within a function and outside of it?</p>