Hi. I have a script that’s collecting data and storing them in an array of PSObjects. There’s variable count of NoteProperty members being added for each PSObject, ie. one object can have 3 NoteProperties, another can have 5 etc.
I want to store the output in a CSV file, but when I use $output | Export-CSV file.csv -NoTypeInformation, where $output is the array, it will only ouput as many properties as the first object in the array has. So for the above example if first object has 3 noteproperties, then only 3 noteproperties are exported for all objects (even if they have more).
I presume the reason is (in my layman terms) that the CSV file header is formed when first object to be exported is read and it’s not “updated” when an object with more noteproperties is encountered?
How can I solve this?
Thanks in advance