This blog article shows you one of the possible ways to read MySQL Server using PowerShell. Firstly, you need to install ADO.Net MySQL driver using the link
https://dev.mysql.com/downloads/connector/net/. The will the following code you should be access to MySQL database.
Param(
[Parameter(
Mandatory = $true,
ParameterSetName = ”,
ValueFromPipeline = $true)]
[string]$Query
)
$MySQLAdminUserName = ‘root’
$MySQLAdminPassword = ‘password’
$MySQLDatabase = ‘sakila’
$MySQLHost = ‘localhost’
$ConnectionString = “server=” + $MySQLHost + “;port=3306;uid=” + $MySQLAdminUserName + “;pwd=” + $MySQLAdminPassword + “;SslMode=none;database=”+$MySQLDatabase
Try {
[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[0]
}
Catch {
Write-Host “ERROR : Unable to run query : $query `n$Error[0]”
}
Finally {
$Connection.Close()
}
Also: Azure Storage download files using PowerShell

Source code download: https://github.com/chanmmn/mysql/tree/main/2025/powershellreadmysql?WT.mc_id=DP-MVP-36769
Reference: https://gist.github.com/ptflp/da75369c7902f96d3a3ce741db6c33b4?WT.mc_id=DP-MVP-36769
Pingback: The version of Windows PowerShell on this computer is ‘5.1.26100.3624’ | Chanmingman's Blog