0
我無法弄清楚如何獲得查詢結果(qty_records),這是5,所以我可以在PowerShell If語句中使用它。如何在'if'語句中使用PowerShell的'invoke-SQLcmd'的結果?
====
$my_query = "select count(CustomerNumber) as qty_records from customers"
$qty_records = Invoke-Sqlcmd -Query $my_query -ServerInstance "2008c" -Username sa -Password abc.1234 -Database MikeDB
if ($qty_records -gt 4) {
write-host "do something"
} else {
Write-Host "do something else"
}
====== 感謝