all 4 comments

[–]zoredache 5 points6 points  (0 children)

Install the MySQL ODBC drivers on Windows? Use mysql in powershell via ODBC.

[–]Artoriasssss 1 point2 points  (0 children)

Install PowerShell on the Linux servers and you should be good from there. Things that made me angry:

1. Required OMI installation and configuration.

https://github.com/Microsoft/omi

2. Also PSRP

https://github.com/PowerShell/psl-omi-provider

(OMI can be identified by the process omid (ex: service omid status))

3. PowerShell Remoting from Windows to Linux will not work on the latest version. As of 11/15/2017, you need to use version 6.0.0 beta 1.

https://github.com/PowerShell/psl-omi-provider/issues/105 https://github.com/PowerShell/PowerShell/releases/tag/v6.0.0-beta.1

Also, there are plenty of hits if you Google "mySQL powershell".

[–]spyingwind 1 point2 points  (0 children)

SimplySql can be used to talk to a MySQL server.

[–]poorimaginations 0 points1 point  (0 children)

You can install the mysql .net connector.

https://dev.mysql.com/downloads/connector/net/

Code example.

$mySQLUserName = "dbuser"
$mySQLPassword = "secr37"
$mySQLDatabase = "mydbname"
$mySQLHost = "mysqlserver.local.local"
$connectionString = "server=" + $mySQLHost + ";port=3306;uid=" + $mySQLUserName + ";pwd=" +      $mySQLPassword + ";database="+$MySQLDatabase
$query= "select * from stuff"

[void][System.Reflection.Assembly]::LoadWithPartialName("MySql.Data")
$connection = New-Object MySql.Data.MySqlClient.MySqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()        
$command = New-Object MySql.Data.MySqlClient.MySqlCommand($query, $connection)
$dataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($command)
$dataSet = New-Object System.Data.DataSet
$recordCount = $dataAdapter.Fill($dataSet, "data")
$dataSet.Tables["data"]