Rather than run my command and then use the mouse in the comand window to copy the output to my paste buffer, like some kind of animal, I wanted to have a full powershell solution.
FOOBAR | Tee-Object -Variable c; Set-Clipboard $c
- FOOBAR is the name of the command (or series of piped commands) that I want to run that write to the console.
- Tee-Object -Variable c takes the output from FOOBAR and passes it forward (in this case to the console output) and to the variable $c.
Tee-Object is kind of like a plumbing tee where data is sent in two directions. It's normally used to show output on the console and to redirect to a file.
Note that you say -Variable c not -Variable $c. - Set-Clipboard $c sets the contents of the paste buffer with the value in $c.
No comments:
Post a Comment