I\'m working with a big text file, I mean more than 100 MB big, and I need to loop through a specific number of lines, a kind of subset so I\'m trying with this,
<
The below is working for me. It extract all the content between 2 lines.
$name = "MDSinfo"
$MDSinfo = "$PSScriptRoot\$name.txt" #create text file
$MDSinfo = gc $MDSinfo
$from = ($MDSinfo | Select-String -pattern "sh feature" | Select-Object LineNumber).LineNumber
$to = ($MDSinfo | Select-String -pattern "sh flogi database " | Select-Object LineNumber).LineNumber
$i = 0
$array = @()
foreach ($line in $MDSinfo)
{
foreach-object { $i++ }
if (($i -gt $from) -and ($i -lt $to))
{
$array += $line
}
}
$array