Accepting input from a file
This process is significantly different in PowerShell, compared to Bash. In Bash, we call the command first, and then ask it to accept input from a file. In PowerShell, we make PowerShell read the contents of the input file first and then send the output to the command that accepts input through the pipeline.
In our recipe, we read the contents of the file, input.txt, which contained a list of four filenames. We used Get-Content to read the content from the file. Get-Content sent the output to the standard output at first, thereby showing us the contents of the file. We then added a pipe to tell PowerShell that we need further processing, and then added Remove-Item to the command chain. (Remove-Item deletes items, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access