How to combine multiple arrays to csv file

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
nashman
Posts: 3
Last visit: Fri Jan 12, 2018 10:24 am

How to combine multiple arrays to csv file

Post by nashman »

>$a = 1,2,3
>$b = 'x','y','z'
>$c= $a + $b
>$c
1
2
3
x
y
z

What I want is:
1x
2y
3z

Furthermore, I want to export this into csv file with two colums (1,2,3) and (x,y,z).

Thanks!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to combine multiple arrays to csv file

Post by jvierra »

You would have to enumerate the two arrays and generate custom objects. The resulting collection can then be exported to a CSV.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked