How are typed properties displayed in untyped DataTable in PowerShell?

The following PowerShell code loads the SQL result into a dataset:

$sqlCommand = "SELECT A, B FROM TestTable"
$connection = New-Object System.Data.OleDb.OleDbConnection $connectionString
$command = New-Object System.Data.OleDb.OleDbCommand $sqlCommand,$connection
$connection.Open()
$adapter = New-Object System.Data.OleDb.OleDbDataAdapter $command
$dataset = New-Object System.Data.DataSet
[void] $adapter.Fill($dataSet)

I am surprised to learn that $ dataset.Tables [0] .Rows [0] .A works! I tried translating the string to Get-Member, and indeed A and B are indicated as properties of the object. Does anyone know why this works? DataSet was not created from XSD. I tried to write the same lines of code in C # and use a debugger, I do not see properties A and B.

+3
source share
1 answer

PowerShell. , , XML-, COM, AD WMI, PowerShell PSObject, , .

+2

Source: https://habr.com/ru/post/1706922/


All Articles