I feel like this should be far easier to figure out , but it looks like it’s not (at least for me)
I have a text file sitting somewhere on a webserver containing a very very simple/basic shell script.
This is the file my keys · GitHub
Now on linux it would be very easy , to select just the keys from that file if i needed to
What is the output of (Invoke-WebRequest -Uri http://keys.domain.com -UseBasicParsing).Content ?
I am able to get the keys using the same expression, but I do Get-Content (cat) from a file(I have saved this as a shell script).
Hi,
Yes … it’s true , it works from a file, but i would rather not save something to disk if i don’t need to
The example with Out-String doesn’t work for me either (or am i doing something wrong) , it displays the whole file on the screen just like without that pipe
Pretty sure that the .Content property for Invoke-WebRequest dumps the string as a single big block, whereas Select-String expects one string per line of content to be able to reliable select.
I guess the simplest way is to check the Count property; if it’s more than 1, it’s split into an array.
$Req = Invoke-WebRequest https://www.google.com
# Wrap in @() to ensure it comes out as an array (even if it's only a single item) with a Count property you can check
@($Req.Content).Count