내 최근 프로젝트는 MySQL 데이터베이스에서 데이터를 쿼리하는 데 powershell을 사용해야하며 좋은 스크립트를 찾는다. 유일한 문제는 스크립트가 항상 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