IIRC: The error you're encountering arises because PowerShell does not automatically interpret $sql as a single MySqlCommand object but rather as an array of MySqlCommand objects (as specified in your parameter declaration). This can cause issues when you try to access properties like CommandText, which do not exist for an array type.
You should change [MySql.Data.MySqlClient.MySqlCommand[]]$sql to [MySql.Data.MySqlClient.MySqlCommand]$sql, which ensures $sql is treated as a single MySqlCommand object.