title: Parameters and PowerShell functions
body: <p>I'm definitely not getting something here:</p>
  
  <p>I'm creating a simple function to replicate a string x times.  I am having some weird problem with the parameter -- it doesn't seem to be recognizing the second parameter.
  When I run the function, it returns an empty string. Further, I think it's lumping the 2 parameters into 1. Here's my code:</p>
  
  <pre>
  <code>
  Function Repeat-String([string]$str, [int]$repeat) {
    $builder = new-object System.Text.StringBuilder
    for ($i = 0; $i -lt $repeat; $i++) {[void]$builder.Append($str)}
    $builder.ToString()
  }</code>
  </pre>
  
  <p>First I dot-source it to load it:</p>
  
  <p><code>. .\RepeatString.ps1</code></p>
  
  <p>And then I execute it like this:</p>
  
  <p><code>Repeat-string("x", 7)</code><br>
  I expected a string of 7 x's. I got an empty string.</p>
  
  <p>I went poking around some more, and I changed the "for" loop.  I replaced the "-lt $repeat" part with "-lt 5", so that I would get a fixed number of repeats.  When I did that, I got the following output (without the quotes):</p>
  
  <p>Repeat-String("x", 7)</p>
  
  <p>"x 7x 7x 7x 7x 7"</p>
  
  <p>It looks as though it is concatenating the $str and $repeat parameters instead of treating them like 2 separate parameters. What am I doing wrong?</p>