I have a script that runs a loop set to run a preset number of 50 items in a section
Need some flexibility as sometimes the total items differ enough that some data is not processed.
What would be the best way to change the script so that instead of a number would run until it came to a text such as Total or EOF ?
for ($i=$Record; $i -lt $Record+50; $i++) is what I am working with (unsuccessfully).
Here is what I have:
$Source = (Get-Content -Path $SourceFile)
$RecordStart = @()
0..$Source.count | % {
# Start of Group
if ($Source[$_] -match 'Group:') { $RecordStart += $_ }
}
$Server = @()
foreach ($Record in $RecordStart) {
for ($i=$Record; $i -lt $Record+50; $i++) {
*** Text Extraction Commands ***
}
} # for $i
$Server | Export-Csv $CSV -NoType
$Server | FT -Auto