I am converting code that currently parse a large csv file once for each agency. Below is what one line looks like:

```
Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.168.532.*"  -or $_Domain -eq     "MYDOMAIN"`
 -and (get-date $_.discovery_timestamp) -gt $PreviousDays} | select-object Hostname","Domain","IP Address","discovery_timestamp","some_version" | `
 Export-Csv -NoTypeInformation -Path $out_data"\OBS_"$Days"_days.txt" 
 write-host "OBS_DONE"

```

I have about 30 of these.
I want to parse the csv file once, possibly using foreach and import.csv.
I thought I could do something like:

```
$HostFile = Import-csv .\HostList.csv 
foreach ($line in $HostFile)
{
Where-Object {$_."IP Address" -Match "^172.31.52.*"} 
write-host $line
#| Export-Csv -NoTypeInformation -Path H:\Case_Scripts\test.csv

```

I've tried many permutations of the above, and it never is matching on the "Where-Object" like it does on the example functioning script above.

Any guidance and learning opportunities are appreciated.