While using the MySql.Data.MySqlClient with the .Parameters.AddWithValue() for some odd reason the first argument of the AddWithValue is returned no matter what. So if you are creating a Function in PowerShell you MUST set some variable or $null to be equal to $oMySQLCommand.Parameters.AddWithValue() otherwise if you are depending on a return from the Function your value will be corrupted by the Argument being returned.
Oddly, it also does not return $false if the value is not found in the .CommandText() either so it seems to have no purpose whatsoever.
Example:
$oMySQLCommand = New-Object MySql.Data.MySqlClient.MySqlCommand
$oMySQLCommand.Connection = $oMySQLPrivilegedConnection
$oMySQLCommand.CommandText = $strMySQL_INSERT
# Must capture the .AddwithValue() else if within a Function and relying on the Return of the function you will be surprised.
$null = $oMySQLCommand.Parameters.AddWithValue("@employeeID", $employeeID)
Oddly, it also does not return $false if the value is not found in the .CommandText() either so it seems to have no purpose whatsoever.
Example:
$oMySQLCommand = New-Object MySql.Data.MySqlClient.MySqlCommand
$oMySQLCommand.Connection = $oMySQLPrivilegedConnection
$oMySQLCommand.CommandText = $strMySQL_INSERT
# Must capture the .AddwithValue() else if within a Function and relying on the Return of the function you will be surprised.
$null = $oMySQLCommand.Parameters.AddWithValue("@employeeID", $employeeID)