Extract data from System.Data.DataRow in powershell
You can also use ItemArray. Prints the entire row, while Item(index) prints the values from the indexed cell.
Item
is a parameterized property, not a list you can index into:
foreach($row in $table){ $row.Item("GroupID")}
or (assuming that "GroupID" is the first column):
foreach($row in $table){ $row.Item(0)}
Assuming the column name is GroupID
$sql = "SELECT [GroupID] FROM theTable"$table = Invoke-SQLCmd -Query $sql -ServerInstance $sqlServerInstance -Database $database -OutputAs DataRowsforeach($user_info in $table){ $user_info.GroupID}
or
foreach($user_info in $table.GroupID){ $user_info}