title: Strange behaviour from MySQL in Powershell
body: <p>I'm new to PowerShell and have a specific question about working with MySQL in PowerShell.</p>
  
  <p>I got this function:</p>
  
  <pre><code>Function run-mySQLInsertQuery{
      param(
          $connection,
          [string[]]$insertQuery
      )
      foreach ($command in $insertQuery){
          $MySQLCommand = $connection.CreateCommand()
          $MySQLCommand.CommandText = $command
          $rowsInserted = $MySQLCommand.ExecuteNonQuery()
          if ($rowsInserted) {
              return $rowsInserted
          } else {
              return $false
          }
      }
  }
  </code></pre>
  
  <p>With this version of the function i get the following Error:</p>
  
  <pre><code>Cause:
  "The CommandText property has not been properly initialized."
  
  Errorline:
          $rowsInserted = $MySQLCommand.ExecuteNonQuery()
  </code></pre>
  
  <p>I searched for a solution and edited my function a bit to the following (for testing purpose):</p>
  
  <pre><code>Function run-mySQLInsertQuery{
      param(
          $connection,
          [string[]]$insertQuery
      )
      $abcd = $insertQuery[1]
      foreach ($command in $insertQuery){
          $MySQLCommand = $connection.CreateCommand()
          $MySQLCommand.CommandText = $abcd
          $rowsInserted = $MySQLCommand.ExecuteNonQuery()
      }
  }
  </code></pre>
  
  <p>With this code, the function executes the query without a problem. My question now is, why? i cant really see a difference, because in <code>$command</code> should be the exact same query like it is in <code>$abcd</code>. Or am I getting something wrong?</p>
  
  <p><strong>EDIT:</strong>
  As its asked it the comments, here is how i call the function:</p>
  
  <pre><code>[String[]]$statements = ""
  
  foreach($key in $arrayStatus.Keys){
      $item = $arrayStatus[$key]
      $insertStatus = "INSERT INTO tx_tphbusinessofferings_domain_model_status (status_id, status) VALUES ('$key', '$item')"
      $statements += $insertStatus
  }
  $Rows = run-mySQLInsertQuery -connection $mySQLconnection -insertQuery $statements
  </code></pre>