Forum Discussion
Haniel Croitoru
Feb 08, 2021Learn Expert
Export-Csv variable object data
Hi,
I'm trying to export an object in PowerShell into a CSV file. My goal is to include all properties in the CSV file ,but find that only properties from the first object are included. For e...
farismalaeb
Feb 08, 2021Steel Contributor
Hi,
Would you please add a bit of code to understand exactly, maybe my bad English did not help me this time.
Are the First Object and the Second object are independent objects or related to the same PSObject
$PS1stobject=@{
Name="First Object"
id = "1"
}
$PS2ndobject=@{
Name="Second Object"
id = "2"
Value="123"
}
$PSFirstObject=New-Object -TypeName PSObject -Property $PS1stobject
$PsSecondObject=New-Object -TypeName PSObject -Property $PS2ndobject
And what you want to do is export the content of both PSObject to the same CSV ?
Thanks
Haniel Croitoru
Feb 08, 2021Learn Expert
farismalaeb , the two objects are in a collection of objects.