1

First of all I would like to clarify that my question is NOT: How to export multi-valued properties (array) into csv file.

My use case is the following: I am creating a code to audit Hyper-V infrastructure and I would like to have in one CSV cell multiple lines. For example: NIC1, NIC2 ... Disk 1, Disk 2. I do not want to use join operator and have it on a single line.

enter image description here

I am almost certain that there was an article about that and that i did managed to achieve the goal, but unfortunately I am not able to find neither the article, neither the scrip in which I have used it.

Any suggestions or ideas would be highly appreciated! :)

mklement0
  • 382,024
  • 64
  • 607
  • 775
Ivan Mirchev
  • 829
  • 5
  • 8
  • 2
    https://stackoverflow.com/questions/24018597/adding-a-newline-character-within-a-cell-csv/24020428 Maybe this might be of help? – Sharpfawkes Jan 12 '20 at 07:52

1 Answers1

1

The hint was submitted by LeroyJD in the comments. @LeroyJD, Thank you very much, helped a lot! :)

To summarize for future reference: Yes, it is possible by using the new line backtick n to present in multiple lines. Sample code:

[PSCustomObject]@{
    Value1 = 'Hello'
    Value2 = "Hello `nWorld"
} | Export-Csv C:\TEMP\multiline.csv -NoTypeInformation

Invoke-Item C:\TEMP\multiline.csv

Which results into:

enter image description here

Thanks again to LeroyJD for the hint!

Ivan Mirchev
  • 829
  • 5
  • 8