When I type the following into Powershell:
>gc test.csv; read-host "readhost"
it gives:
"header"
"data 1"
"data 2"
readhost:
(header, data 1, data2 are the correct contents of test.csv, user input return is required after the 'readhost:')
However, when I type:
>import-csv test.csv; $line2 = read-host "readhost"
It gives:
readhost: #user presses return key
header
------
data 1
data 2
For some reason that I cannot find online the read-host
has executed before the import-csv
.
I've tried to put read host
in a function and calling that but it did not correct the order.
I read a similar question-answer that suggested piping to write-host
however this disrupts the csv output format.
Why does the read-host
executed before the import-csv
and how can I prevent this?