Hello all, I am trying to read a datatable with powershell and I am reaching a roadblock maybe someone could help with.
Here is what I am doing.
$hostname = "host01"
$con = "server=$hostname;database=HostLog;Integrated Security=sspi"
$cmd = "select top 5 DBsizeInMB from TestLog
$da = new-object System.Data.SqlClient.SqlDataAdapter ($cmd, $con)
$dt = new-object System.Data.DataTable
$da.fill($dt) | out-null
$dt | Format-Table -autosize
My output looks like
Now my question is how would I select say the 2nd entry in DBsizeInMB? the number would be 35425.
I would eventualy like to turn it into a variable.
I have tryed
My end goal is to create variables out of each row of data.
$item1 = $dt.tables
$item2 = $dt.tables
$item3 = $dt.tables