January 28, 2018 ยท 5 min read
powershell
How to copy stdout to the clipboard in Powershell
Archived from the old blog. Original URL: https://tomauger.gitlab.io/posts/2018-01-28-how-to-copy-stdout-to-the-clipboard-powershell/.
Suppose you want to copy the output of a Powershell command to the clipboard. Instead of making a mess of selecting the output in the terminal and copying, just pipe the output to clip.
For example to copy your path environment variable to the clipboard run:
$Env:Path | clip
The same can also be achieved using Set-Clipboard:
$Env:Path | Set-Clipboard
To read the contents of the clipboard use Get-Clipboard:
$content = Get-Clipboard