How to combine multiple arrays to csv file

Ask your Windows 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.
Locked
User avatar
nashman
Posts: 3
Joined: Tue Jan 09, 2018 7:48 am

How to combine multiple arrays to csv file

Post by nashman » Thu Jan 11, 2018 7:32 am

>$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!

User avatar
jvierra
Posts: 12086
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to combine multiple arrays to csv file

Post by jvierra » Thu Jan 11, 2018 7:39 am

You would have to enumerate the two arrays and generate custom objects. The resulting collection can then be exported to a CSV.

Locked