How to copy stdout to the clipboard in 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


comments powered by Disqus