我编写了一个简单的 powershell 脚本,它检查 PSA 服务板上的票数并输出票数和与之相关的颜色。但是,我的脚本在结果之前打印了一个“1”。我对powershell很陌生,我似乎找不到可以打印这个的行。任何帮助,将不胜感激。谢谢
$SqlServer = "server"
$SqlCatalog = "database"
$SqlQuery = "SELECT COUNT(*) FROM v_rpt_Service WHERE Board_Name = 'Traige' AND Parent = ''"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SqlServer; Database = $SqlCatalog; uid = user; pwd = pass"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$value = $DataSet.Tables[0].Rows[0][0]
$color = "Red"
if($value -lt 4){
$color = "Yellow"
}
if($value -lt 1){
$color = "Green"
}
$obj = new-object System.object
add-member -inputobject $obj -membertype NoteProperty -Name Tickets -value $value
add-member -inputobject $obj -membertype NoteProperty -Name Color -value $color
$obj