https://brianreiter.org/2010/01/29/powershells-object-pipeli...
https://brianreiter.org/2010/01/29/powershells-object-pipeli...
I bet it still truncates output of the ">" operator to the console width, too.
'troll' * 1000 > out.txt
Open in NotePad++, no weird newlines in the wrong place, content not truncated.Were you using |format-table and |format-list (ft, fl) to explicitly format the text for console viewing, then redirecting that to a file?
'troll' * 1000 > troll.txt
.. works fine as you say Select-String -Path .\troll.txt -Pattern "t" > t.txt
.. wraps the output at the console width. Which means you can't use it as a grep replacement. Select-String -Path .\troll.txt -Pattern "t" | Set-Content t.txt
or
sls 't' .\troll.txt | sc t.txtThis is the main reason I still use cmd.exe
One performance tip I picked up early on: If you're passing around large object sets you need to operate on try to keep them in a pipeline. Populating a variable and interacting with it is arguably more readable and maintainable, especially for junior people, but it has a heavy cost in terms of memory.
That said every version of posh is better than the last so I may be wrong or overestimating the impact for the newest versions. YMMV, don't believe everything you read on the internet, etc.
Jeffrey Snover [MSFT]
If you don't pass the flags zo handle it as binary in those cases stuff breaks.
Piped binary data, not corrupted, since a long time before that blog post was written.
What you can't do is run native commands, and read their standard output as a byte stream without going through .Net and Start-Process.
"The backups fail to restore" is such a common occurrence, it's really scary.