Powershell and some simple string manipulation -


To help with some basic string manipulation, some help is needed to create a power script, I only have trouble with enough power I know how to get in, but it can not understand syntax or coding to work.

I have a text file that looks like this -

  Here is the list of servers: server1 server 2.domain.local server3 number of total servers : 3   

I have to take that text file and leave the first and last lines (always the first and the last). Then I should take every second line and basically put it in a CSV file Must have changed.

The final output should be a text file that looks like this -

  server1, server2.domain.local, server3   

You can try:

  $ a = Content C : \ Temp \ M.TXT # where M.TXT is your original file $ one [1. ($ A.count-2)] | % {$ S = ""} {$ s + = $ _ + ","} {$ s.trim (",") | Out-file m.csv} is the # M.CSV result file    

Comments