我最近的项目需要使用PowerShell查询从MySQL数据库中的数据,我找到一个很好的脚本来做到这一点,唯一的问题是,脚本总是输出int值(精确地返回项目的数量) 。如何避免这种输出?我唯一想获得的是查询数据。 下面是脚本:如何在使用powershell脚本查询数据库时避免int值输出?
$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]
和脚本的输出为:
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
如何避免输出值“2”?
的〔请告诉我更好(清洁器)的方式来忽略PowerShell的输出(http://stackoverflow.com/questions/5260125/whats-the-better-cleaner-way-to-ignore-output-in可能重复-powershell) – Matt 2014-10-30 11:58:09