title: Powershell - adding two variables together receiving numbers from command line
body: <p>I am trying to receive input from the command line, such as adding two numbers, but I either return the literal variable number, the number 0, or invalid data. </p>
  
  <p>With this code: </p>
  
  <pre><code>Param (
      [int]$a, 
      [int]$b
  )
  function add([int]$a,[int]$b)
  {
      $var = $a+"$b"
      $a
      $b
      $var
      return $a + $b
  }
  
  add([int]$a,[int]$b)
  </code></pre>
  
  <p>This is the error I receive with this. </p>
  
  <pre><code>PS C:\&gt; .\add.ps1 -a 5 -b 4
  add : Cannot process argument transformation on parameter 'a'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32".
  At C:\add.ps1:15 char:4
  + add &lt;&lt;&lt;&lt; ([int]$a,[int]$b)
      + CategoryInfo          : InvalidData: (:) [add], ParameterBindin...mationException
      + FullyQualifiedErrorId : ParameterArgumentTransformationError,add
  </code></pre>
  
  <p>And then with </p>
  
  <pre><code>Param (
      [int]$a, 
      [int]$b
  )
  function add([int]$a,[int]$b)
  {
      $var = $a+"$b"
      $a
      $b
      $var
      return $a + $b
  }
  
  add
  </code></pre>
  
  <p>It returns nothing but 0's. Then when I use this code: </p>
  
  <pre><code>Param (
      [int]$a, 
      [int]$b
  )
  function add($a,$b)
  {
      $var = $a+"$b"
      $a
      $b
      $var
      return $a + $b
  }
  
  add($a,$b)
  </code></pre>
  
  <p>It just returns what I give as a command line argument. I am calling this program like this:</p>
  
  <p><code>.\add.ps1 -a 5 -b 4</code></p>
  
  <p>There's gotta be something I'm not doing correctly with Powershell. However, I'm not sure what terms, or how I should word my search because I get how to concatenate the variables, or just add plain integers, but not two variables with integers passed from the command line, in a function. </p>