I have this PSCustomObject which I'm trying to format into a table and export it to an .csv file, when the .csv file is built, the output in the cell is System.Object[].
$tableFindings = @()
foreach ($item in $findings.results) {
$tabledata = [ordered]@{
dnsName = $item.assets| ForEach-Object dsnName
}
$tableFindings += New-Object psobject -Property $tabledata
}
$tableFindings outputs
{
"temporary_id": "xxxxxxxxxxxxxxxxxx",
"affects_rating": true,
"assets": [
{
"asset": "xxxxxxxx",
"identifier": null,
"category": "critical",
"dnsName": [
"xxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxx"
],
"is_ip": false
},
{
"asset": "xxxxxxxx",
"identifier": null,
"category": "critical",
"dnsName": [
"xxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxx"
],
"is_ip": false
}
]
}
I'm having a hard time trying to figure out how to access the array of objects, assets is one of the arrays, but inside there is dnsName that is also an array.
Any suggestions?