Convert single-line .CGI to Multiline in Powershell

21 Views Asked by At

I have a media application that outputs the playlist into a handy .CGI web file. When viewing from browser (view-source:http://) is shows it as a list (line 1, 2, 3 etc); however Powershell's Invoke-WebRequest pulls it as one string that's X chars long.

Is there away of having powershell pull the data much the same as the browser views it.

My goal is to be able to select specific lines, say track 4 & 5, -Skip 3, -First 1, etc I was steering away from exporting it out to text and then importing back...

Thanks

1

There are 1 best solutions below

0
Mathias R. Jessen On

The Content property on the response object you get from Invoke-WebRequest contains a single multi-line string - simply split on newlines to get each line as individual strings:

$webResponse = Invoke-WebRequest ...

$responseBodyLines = $webResponse.Content -split '\r?\n'