I am trying to go through a variable, line by line, and apply regex to parse the string within it.
I am downloading the data via invoke-restmethod and am trying to do the below
$result= invoke-restmethod -uri $uri -method get
foreach($line in $result)
if($line -match $regex)
{
#parsing
}
the above doesn't work as their is only one line. But when I output result into a file and then apply the above logic it works, like so
$result= invoke-restmethod -uri $uri -method get
$result >> $filelocation
$file = get-content $file
foreach($line in $file)
if($line -match $regex)
{
#parsing
}
The script is time critical so I don't have the luxury to write to a file and then reopen, how could I achieve the above without using get-content?