Splitting text file with separators

Hello!
I have a text file which contains 4 sections separated by strings with specific patterns. The file is being updated irregularly, manually and by several people.
I wrote a script which allows me to split this file into 4 variables for further processing:

$grouplist = get-content .\list.cfg | where {$_ -notlike “#*”} #excluding comments
for ($i=0; $i -le ($grouplist.length-1); $i++) {
if ($grouplist[$i].startswith(‘=OK’)) {[Int32]$StOKPos=$i}
if ($grouplist[$i].startswith(‘=NS’)) {[Int32]$StNSPos=$i}
if ($grouplist[$i].startswith(‘=NK’)) {[Int32]$StNKPos=$i}
if ($grouplist[$i].startswith(‘=li’)) {[Int32]$StLIPos=$i}
}
$OKlist=($grouplist[($StOKPos+1)…($StNSPos-1)] | where {$_ -notcontains “=”})
$NSlist=($grouplist[($StNSPos+1)…($StNKPos-1)] | where {$_ -notcontains “=”})
$NKlist=($grouplist[($StNKPos+1)…($StLIPos-1)] | where {$_ -notcontains “=”})
$LIlist=($grouplist[($StLIPos+1)…($grouplist.length-1)] | where {$_ -notcontains “=”})

But I think there could be more shorter and neater solution. Any ideas?

Can you post a sample of the input data?

Sure:

####tagfile###############
#Passed tags
=OK========================
pass1
pass2
pass3
#For reviewing
=NS========================
rev1
rev2
rev3
#Not passed
=NK=========================
notok1
notok2
notok3
#in process
=LI========================
live1
live2
live3