Set-Clipboard
Copy output to the clipboard
Get-ChildItem -Name | Set-Clipboard
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Set-Clipboard
- PowerShell 7 Works on Linux (needs xclip) and macOS as well as Windows.
Sends whatever comes down the pipeline to the clipboard. Paste it anywhere with Ctrl+V.
Objects are turned into text first. For a tidy table that pastes into Excel as columns, convert to tab-separated text:
Try this
Get-Process |
Select-Object -First 10 Name, Id, CPU |
ConvertTo-Csv -Delimiter "`t" -NoTypeInformation |
Set-Clipboard
-Append adds to what is already on the clipboard.
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | ls | pbcopy |
| cmd.exe | dir /b | clip |
More in From bash and From cmd.