0

I used the ">" operator to put the content of an array into a CSV file, here is what i got, the first line is empty

Computer                                                    IP                                                         
--------                                                    --                                                         
IMPPRD1                                                     172.22.30.33                                               
IMPPRD2                                                     172.22.30.31                                               
IMPPRD3                                                     172.22.30.32                                               
IMPSR1                                                      172.22.30.12                                               
IMPPRD5                                                     172.22.30.17    

I would like it to be a normal CSV, so something like this :

Computer,IP                                                                                                        
IMPPRD1,172.22.30.33                                               
IMPPRD2,172.22.30.31                                               
IMPPRD3,172.22.30.32                                               
IMPSR1,172.22.30.12         

How could I manage to do this using powershell? Thanks !

2
  • 2
    Have you tried $array | Export-Csv filename ? Commented May 18, 2015 at 17:15
  • Yeaaaah, I already tried it but I didn't think of putting the pipe, haha, nice, thanks alot Commented May 18, 2015 at 17:19

1 Answer 1

2

Using > outputs as normal text - including the spaces between columns. Basically the same as Write-Output. You are looking for Export-Csv which outputs in CSV format.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.