If you hundreds or thousands of entries in the csv, it will take some time to save that amount of data on each loop.
I would think it would be better to maintain a count in a file that indicates how many rows were processed. On restart, just skip the rows until you hit the count.
$PointerFile = 'c:\temp\Pointer.txt' # del c:\temp\Pointer.txt to start over
$csv = import-csv -Path C:\temp\test.csv
If (test-path $PointerFile) {
$StartAt = [int](get-content -path $PointerFile)
"Restarting at line {0}" -f $StartAt
} else {
$StartAt = 0
"Starting at first entry."
}
$counter = 1
foreach ($Row in $csv) {
if ($counter -lt $StartAt) {
"Skipping {0}" -f $counter
$counter++ # look to next row
continue # This entry has been processed
}
# process the row here
$counter++
$counter | out-file $PointerFile # save the counter to our file
start-sleep 5 # delay for testing, remove this line when running for real
}