title: Powershell 5 : Cannot convert value To System.String
body: <p>I have a PS script with which I read a csv file line by line into a variable :</p>
  <p>CSV :</p>
  <pre><code>  header1;header2
    column1;column2
  </code></pre>
  <p>PS Script :</p>
  <pre><code>#-------------------------
  #   Func declarations    
  #-------------------------
  function myFunc{
     param(
      [Parameter(Mandatory=$true)][string]$param1,
      [Parameter(Mandatory=$true)][string]$param2
     )
     #Do something
  }
  
  #-------------------------
  #       Run    
  #-------------------------
  
  $lines = Import-Csv .\etc\file.csv -Delimiter &quot;;&quot; -Header &quot;header1&quot;,&quot;header2&quot;
  
  foreach($line in $lines) {
      myFunc -param1 $line.header1 -param2 $line.header1
  }
  </code></pre>
  <p>The call
  <code>myFunc -param1 $line.header1</code> throws a:</p>
  <blockquote>
  <p>Cannot convert value To
  System.String (...) ParameterBindingArgumentTransformationException</p>
  </blockquote>
  <p>Checking the type of $line.header1 (or $line.header2)  with <code>$line.header1.GetType()</code> returns as expected <code>System.string</code>.</p>
  <ul>
  <li>If I remove one parameter (whichever), it works</li>
  <li>If I remove the type
  definition on the first like so :
  <code>[Parameter(Mandatory=$true)]$param1</code>, the first one is recognized
  but the second is null...</li>
  </ul>
  <p>Why?</p>