Get-Clipboard
Read what is on the clipboard
Get-Clipboard
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Get-Clipboard
- PowerShell 7 Works on Linux (needs xclip) and macOS as well as Windows.
Returns the clipboard text, one line per string. Handy for cleaning up a list someone pasted you in chat.
Try this
Copy a list of names, then remove blanks and duplicates and put it back:
Get-Clipboard |
ForEach-Object { $_.Trim() } |
Where-Object { $_ } |
Sort-Object -Unique |
Set-Clipboard
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | pbpaste |
More in From bash and From cmd.