I am brand new to PS so if I sound like I don’t know what I am talking about, its because I don’t.
I pilfered a script that pings hostnames and returns the IP address. The result is written to a csv. This all works well. However it writes the hostname and IP address in the same cell. How can I write them to different columns?
Thank you for your response, tonyd! I tried to paste this into my code, but it isn’t working. I get an RPC Server not available error. This is what I am using for those lines:
Well, I have to admit, I did not test opening in Excel, my bad on that. I created a new CSV in excel, compared that to the output of the PowerShell, and no difference. Yet, opening each file individually obtained different results. The PS output opened in one cell as you state.
Sadly, I dont have the time to get this figured, but there is a workaround. You can open a blank Excel document, go to the Data tab and select “From Text/CSV” and open your file that way.
I think the master Olaf will have an answer for you at some point. I will play more when I have the time.
I’d recommend to work with objects and properties instead of strings and to use Export-Csv instead of Out-File for the output to a CSV file…
And depending on your locale setting you could try to use another delimiter for your CSV files. For German systems for example we have to use semikolons to get Excel to recognize it as the default delimiter for CSV files.