Q:

populating DataTable from PSObject

I am an absolute beginner when it comes to PS scripts and am heavily struggling with what I thougt a simple thing: iterating over PSObject items to combine them into 1 array.
I have written a simple Invoke-RestMethod based script that'll fetch me DNS configuration for one of the services I am using.
The output I get from their API is a JSON, which (when consumed by Invoke-RestMethod) is turned into customPSObject, with following structure:

dns

dkim1

valid
host
type
data

dkim2

valid
host
type
data

domain_cname

valid
host
type
data

owner_cname

valid
host
type
data

mail_cname

valid
host
type
data

currently I am using following code to get the results:
$res = Add-SGAuthDomains $SGapiKeyName $SGsubUserName

$strng = $res.Body.dns.dkim1 | Out-String
Write-Host $strng

$strng = $res.Body.dns.dkim2 | Out-String
Write-Host $strng
(...)

but, as you can see, this produces separate tables. What I would like to have, is all those results being in a single table.
I have tried using DataTable as per code below, 
$dnsConf = New-Object System.Data.DataTable
[void]$dnsConf.Columns.Add("valid")
[void]$dnsConf.Columns.Add("host")
[void]$dnsConf.Columns.Add("type")
[void]$dnsConf.Columns.Add("data")

foreach ($item in $res.Body.dns) {
    $($item | Get-Member -MemberType *Property).Value
    [void]$dnsConf.Rows.Add($item.valid, $item.host, $item.type, $item.data)
}

$dnsConf | Format-Table

but that did not produce any output. What am I doing wrong?
This is the output I am getting:
valid type  host                    data
----- ----  ----                    ----
False cname em9570.justchecking.xyz u13091771.wl022.sendgrid.net

valid type  host                           data
----- ----  ----                           ----
False cname s1._domainkey.justchecking.xyz s1.domainkey.u13091771.wl022.sendgrid.net

valid type  host                           data
----- ----  ----                           ----
False cname s2._domainkey.justchecking.xyz s2.domainkey.u13091771.wl022.sendgrid.net

valid type  host                     data
----- ----  ----                     ----
False cname url3844.justchecking.xyz sendgrid.net

valid type  host                      data
----- ----  ----                      ----
False cname 13091771.justchecking.xyz sendgrid.net

and this is how I would like it to be:
valid type  host                    data
----- ----  ----                    ----
False cname em9570.justchecking.xyz u13091771.wl022.sendgrid.net
False cname s1._domainkey.justchecking.xyz s1.domainkey.u13091771.wl022.sendgrid.net
False cname s2._domainkey.justchecking.xyz s2.domainkey.u13091771.wl022.sendgrid.net
False cname url3844.justchecking.xyz sendgrid.net
False cname 13091771.justchecking.xyz sendgrid.net

A:

Selecting properties from different objects can be done by combining them in one big array. This will only work when all objects in the array have the same properties.
$res = @{
    Body = @{
        dns = @{
            dkim1 = @(
                [PSCustomObject]@{
                    valid = $false
                    type  = 'dkms1 name A'
                    host  = 'dkms1 host A'
                    data  = 'dkms1 data A'
                }
                [PSCustomObject]@{
                    valid = $false
                    type  = 'dkms1 name B'
                    host  = 'dkms1 host B'
                    data  = 'dkms1 data B'
                }
            )
            dkim2 = @(
                [PSCustomObject]@{
                    valid = $false
                    type  = 'dkms2 name A'
                    host  = 'dkms2 host A'
                    data  = 'dkms2 data A'
                }
                [PSCustomObject]@{
                    valid = $false
                    type  = 'dkms2 name B'
                    host  = 'dkms2 host B'
                    data  = 'dkms2 data B'
                }
            )
        }
    }
}

@($res.Body.dns.dkim1, $res.Body.dns.dkim2) | Format-Table

Will result in:
valid type         host         data
----- ----         ----         ----
False dkms1 name A dkms1 host A dkms1 data A
False dkms1 name B dkms1 host B dkms1 data B
False dkms2 name A dkms2 host A dkms2 data A
False dkms2 name B dkms2 host B dkms2 data B

