![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | FEATURE REQUEST: redirecting output to non-file objects It would be nice to be able to redirect output to objects that are not files. For instance: $x = new-object Collections.ArrayList doSomething >$x # collect items in ArrayList or $x = new-object Text.StringBuilder doSomething >$x # collect items in a stringbuilder rather than a text file You might say that I should simply write a function: function toStringBuilder($sb) { begin { $local:sb = new-object Text.StringBuilder } process { $sb.Append([string]$_) } end { return $sb } } and do: $sb = doSomething | toStringBuilder But this does not work consistently. What if I want to send the ERROR stream to it? Redirection would handle it: $x = new-object Text.StringBuilder doSomething 2>$x # send errors to $x A function would not, right? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: FEATURE REQUEST: redirecting output to non-file objects "Adam Milazzo [MSFT]" <adamm@san.rr.com> wrote in message news:Oyyji5avGHA.976@TK2MSFTNGP05.phx.gbl... > It would be nice to be able to redirect output to objects that are not > files. Interesting idea but I think the problem you run into is that the shell won't know which object member to use to append the pipeline object. I guess the team could use a configuration file like they do for type/formatting data. Still not sure if that is how I would expect the system to work. -- Keith |
My System Specs![]() |
| | #3 (permalink) |
| | Re: FEATURE REQUEST: redirecting output to non-file objects Keith Hill [MVP] wrote: > "Adam Milazzo [MSFT]" <adamm@san.rr.com> wrote in message > news:Oyyji5avGHA.976@TK2MSFTNGP05.phx.gbl... >> It would be nice to be able to redirect output to objects that are not >> files. > > Interesting idea but I think the problem you run into is that the shell > won't know which object member to use to append the pipeline object. I > guess the team could use a configuration file like they do for > type/formatting data. Still not sure if that is how I would expect the > system to work. Yeah. Well, they could use the IList interface to work with any object that supported it. That would take care of ArrayList and many other collections. I don't think this is such a great feature all by itself, but it'd be useful in conjunction with the ability to background tasks (since they couldn't output to the console, and outputting to a text file loses information). % longRunningTask >$list & [1]+ longRunningTask (running) % go about other work... [1]- longRunningTask (complete) % $list # get my results |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Standard output redirecting | PowerShell | |||
| Redirecting output to log file | PowerShell | |||
| Redirecting Output in Powershell | PowerShell | |||
| redirecting file output to .exe | PowerShell | |||
| Many null characters in output when redirecting third party tool to a file | PowerShell | |||