my recent project need to use powershell to query data from mysql database, and I find a good script to do it, the only issue is that the script will always output a int value (which is exactly the number of the return item). How to avoid this output? The only thing I want to get is the query data. The following is the script:
$mysqlDllFilePath = "C:\temp\powerShellScript\MySQL.Data.dll"
[void][system.reflection.Assembly]::LoadFrom($mysqlDllFilePath)
$myconnection = New-Object MySql.Data.MySqlClient.MySqlConnection
$myconnection.ConnectionString = "server=localhost;userid=root;password=admin;database=temp;pooling=false"
$myconnection.Open()
$mycommand = New-Object MySql.Data.MySqlClient.MySqlCommand
$mycommand.Connection = $myconnection
$mycommand.CommandText = "SELECT SiteGuid,SiteName,ProductEdition,ProductVersion from site"
$adapter = new-object MySql.Data.MySqlClient.MySqlDataAdapter
$adapter.SelectCommand = $mycommand
$ds = new-object System.Data.DataSet
$adapter.Fill($ds)
$myconnection.close()
$ds.Tables[0]
And the output of the script is:
PS C:\Users\jason> C:\temp\powerShellScript\Get-ConfigSite.ps1
2
SiteGuid SiteName ProductEdition ProductVersion
-------- -------- -------------- --------------
123f7267-757c-4864-b0... simulatedSite PLT 7.1
526f7267-757c-4864-b0... simulatedSite PLT 7.1
How to avoid output value "2"??