← Back to Blog

Developers & Code | Oct 5, 2026 | 6 min read

The PowerShell Clipboard Cheat Sheet (2026)

By Deepender Yadav

The PowerShell Clipboard Cheat Sheet (2026) — Edge Drop Guide

PowerShell can read and write the Windows clipboard without any module: two cmdlets, a handful of parameters, and the ancient clip.exe fallback. This is the complete reference, tested against Microsoft's current documentation. Older guides floating around are stale on one point: several claim PowerShell Core lacks these cmdlets. Get-Clipboard and Set-Clipboard exist in PowerShell 7.x. The notes below say where each parameter came from.

The two cmdlets

Set-Clipboard sets the current Windows clipboard entry. Get-Clipboard gets it. That is the whole surface. Everything else is parameters.

Set-Clipboard

Set-Clipboard -Value "This is a test string"

The -Value parameter takes a string array: the content to copy. It is also the pipeline target, so this is the idiom you will use most:

Get-Content C:\Users\user1\.ssh\id_ed25519.pub | Set-Clipboard

That example is straight from Microsoft's docs: pipe a file's contents to the clipboard, then paste the key into GitHub.

Parameters worth knowing:

  • -Append adds to the clipboard instead of replacing it, after a newline. Without it, Set-Clipboard clears first.
  • -AsHtml renders the content as HTML on the clipboard, so a paste into a rich editor keeps markup.
  • -Path copies file paths to the clipboard (wildcards allowed): Set-Clipboard -Path "C:\Staging\" puts the folder's files on the clipboard as a file drop list. Paste into Explorer to copy them.
  • -LiteralPath is the same but takes the path exactly as written, no wildcard interpretation. Use it when paths contain brackets or other wildcard characters.
  • -AsOSC52 (PowerShell 7.4 and later) fixes the SSH case: over a remote session, Set-Clipboard normally sets the remote machine's clipboard. This parameter uses the OSC52 escape sequence to set your local machine's clipboard instead. Your terminal must support OSC52; Windows Terminal does.

The cmdlet's alias is clip. In a script, warn the user before overwriting their clipboard; silently replacing it is rude.

Get-Clipboard

Set-Clipboard -Value 'hello world'
Get-Clipboard

Multiple lines come back as an array of strings, like Get-Content. Add -Raw to get one multiline string instead.

  • -Format selects non-text formats: Text, FileDropList, Image, Audio. Get-Clipboard -Format FileDropList lists copied files as file objects, which you can then move or inspect.
  • -TextFormatType selects the text flavor: Text, UnicodeText, Rtf, Html, CommaSeparatedValue. Copy a table from a web page and Get-Clipboard -TextFormatType Html gives you the raw HTML fragment.

The clip.exe fallback

Older than PowerShell and still everywhere: clip.exe reads stdin and puts it on the clipboard.

ipconfig | clip

Now the ipconfig output is on the clipboard, ready to paste. This works in cmd, PowerShell, and batch files with no cmdlet knowledge. It is write-only; there is no unclip. For reading, you need Get-Clipboard.

Copying file paths

Two different jobs, two commands. To copy the list of files (so Explorer pastes the files): Set-Clipboard -Path "C:\Staging\*". To copy a path as text (so a terminal gets the string): build the string and use -Value, or use the dedicated guide How to Copy a File Path to the Clipboard. Mixing these up is the classic mistake; the distinction is Files vs File Contents: What Does Copy Actually Store?.

Terminal and SSH notes

Copying from Windows Terminal can mangle control codes; the cleanup is How to Copy From Windows Terminal Without Garbled Text. Over SSH, remember the 7.4 -AsOSC52 parameter, and note the platform gaps Microsoft documents: on Linux the cmdlets need xclip in the path, on macOS they use pbpaste. These cmdlets are Windows-first citizens.

Pasting HTML with formatting intact

The -AsHtml parameter renders content as HTML on the clipboard, so rich editors receive markup instead of flat text:

$html = "<b>Bold</b> and <i>italic</i>"
Set-Clipboard -Value $html -AsHtml

Paste into Word or Outlook and the formatting survives. Without -AsHtml, the same string pastes as literal tags. This is the scripted version of the copy-format problem covered in How Windows Treats Rich Text vs Plain Text.

Saving a copied image to a file

Get-Clipboard -Format Image returns the image as an object. To save it:

$img = Get-Clipboard -Format Image
$img.Save("C:\Temp\clip.png")

Screenshots copied with Win+Shift+S land on the clipboard as images, and this is the scripted way to file them without pasting into Paint. Pair it with a clipboard manager's image history (How to Keep the Last Ten Screenshots Handy) for the interactive version.

Common mistakes

  • Forgetting -Raw: Get-Clipboard returns an array, so string comparison against the whole clipboard fails line by line. Use -Raw when you want one string.
  • Piping objects directly: Get-Process | Set-Clipboard writes object type names, not useful text. Pipe through Out-String first.
  • Assuming clip reads: clip is write-only. There is no inverse; use Get-Clipboard.
  • Overwriting without warning in shared scripts: always confirm before Set-Clipboard in anything another person runs.

Quick reference

JobCommand
Copy textSet-Clipboard -Value "text" or `"text" \clip`
Copy command output`ipconfig \clip`
Copy a file's contents`Get-Content file.txt \Set-Clipboard`
Append instead of replaceSet-Clipboard -Value "more" -Append
Copy files (as files)Set-Clipboard -Path "C:\Dir\*"
Read clipboard textGet-Clipboard
Read as one stringGet-Clipboard -Raw
List copied filesGet-Clipboard -Format FileDropList
Get HTML sourceGet-Clipboard -TextFormatType Html
Set HTML contentSet-Clipboard -Value $html -AsHtml
Empty the clipboardSet-Clipboard -Value ""
SSH: set local clipboardSet-Clipboard -Value "x" -AsOSC52

Related reading

Sources

  • Microsoft Learn: Set-Clipboard (parameters -Append, -AsHtml, -Path, -LiteralPath, -AsOSC52 added in 7.4): https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-clipboard?view=powershell-7.5
  • Microsoft Learn: Get-Clipboard (-Raw, -Format, -TextFormatType; xclip/pbpaste platform notes): https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-clipboard?view=powershell-7.5
  • MicrosoftDocs PowerShell-Docs on GitHub: Set-Clipboard and Get-Clipboard reference: https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/5.1/Microsoft.PowerShell.Management/Set-Clipboard.md
  • SS64: Set-Clipboard reference (alias clip, scripting notes): https://ss64.com/ps/set-clipboard.html
Deepender Yadav
Written by Deepender Yadav · Author & Developer

Deepender Yadav is a B.Tech Computer Science Engineering student and software developer interested in building practical software and open-source projects.

GitHub · LinkedIn

Copy. Stack. Drop.

Transform your clipboard into an interactive edge shelf. Stack, pin, and drag assets into any app with zero friction.

Download for Windows Get from Microsoft Store

How to Install Guide · First 10 Minutes Guide · Drag & Drop Guide · Edge-Drop vs Win+V · Support

Free · Lightweight · Privacy First
Find us on CodeHype