I just have a short question. I have a PowerShell script that insert rows into a Postgres table using \copy command. No issue at load, everything goes well.
After the load done, I would like to query the table to count the number of rows inserted and being able to test the value retrieved in my Powershell.
So my problem is to retrieve the result of the Postgres table row count into a PowerShell variable.
I found the below code but even if it does not generates errors it does not return the number of rows in my table.
thanks a lot for your support
$DBCmd = $DBConn.CreateCommand()
$DBCmd.CommandText = "SELECT COUNT(*) FROM $Load_table_path WHERE audit_trail = '$MyAudit_trail'"
$rdr = $DBCmd.ExecuteReader()
$dt = [System.Data.DataTable]::new()
$dt.Load($rdr)
$dt.Column1
$testtt = $dt.Column1