I have this simple powershell script which simply reads the arguments from stdin. Nothing else. The problem I have is that this also prints what it reads. How can I stop that? The end goal I have with this is writing a program that takes a file (input via stdin), transforms it, then outputs to stdout. But if it's going to output the input first, the whole thing won't work, so I am already blocked at the first step.
$lines=while($x=read-host){$x}
$lines
Called like this:
echo hello | powershell .\myScript.ps1
Expected output:
hello
Actual output:
hello
hello
What can I do to avoid this problem? My expectation would have been that it doesn't output the result of the assignment.
Of course I can workaround by simply taking the file name as parameter instead, but I would like to learn how this use case can be made to work.